|
|
@@ -301,20 +301,39 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
public ActionResult AssignDeviationToEntity(int siteId, string sourceKey, string targetKey)
|
|
|
{
|
|
|
if (!sourceKey.StartsWith("d"))
|
|
|
+ return new EmptyResult();
|
|
|
+
|
|
|
+ if (sourceKey == targetKey)
|
|
|
+ return new EmptyResult();
|
|
|
+
|
|
|
+ var determinedTargetKey = targetKey;
|
|
|
+
|
|
|
+ if (targetKey.StartsWith("d"))
|
|
|
{
|
|
|
- return new JsonResult
|
|
|
- {
|
|
|
- Data = "invalidSourceKey"
|
|
|
- };
|
|
|
+ return new EmptyResult();
|
|
|
+ //var targetDeviationId = Convert.ToInt32(sourceKey.Replace("d_", String.Empty));
|
|
|
+ //var targetDeviation = _deviationService.GetDeviationById(targetDeviationId);
|
|
|
+
|
|
|
+ //if (targetDeviation == null)
|
|
|
+ // return new EmptyResult();
|
|
|
+
|
|
|
+ //if (targetDeviation.Site != null)
|
|
|
+ // determinedTargetKey = "a_0";
|
|
|
+
|
|
|
+ //if (targetDeviation.Appendix != null)
|
|
|
+ // determinedTargetKey = String.Format("a_{0}", targetDeviation.AppendixId);
|
|
|
}
|
|
|
|
|
|
var deviationId = Convert.ToInt32(sourceKey.Replace("d_", String.Empty));
|
|
|
var deviation = _deviationService.GetDeviationById(deviationId);
|
|
|
|
|
|
- if (targetKey == "a_0")
|
|
|
+ if (determinedTargetKey == "a_0")
|
|
|
{
|
|
|
var site = _siteService.GetSiteById(siteId);
|
|
|
|
|
|
+ if (deviation.Site != null)
|
|
|
+ return new EmptyResult();
|
|
|
+
|
|
|
deviation.Appendix = null;
|
|
|
deviation.AppendixId = null;
|
|
|
|
|
|
@@ -325,9 +344,12 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var appendixId = Convert.ToInt32(targetKey.Replace("a_", String.Empty));
|
|
|
+ var appendixId = Convert.ToInt32(determinedTargetKey.Replace("a_", String.Empty));
|
|
|
var appendix = _appendixService.GetAppendixById(appendixId);
|
|
|
|
|
|
+ if (deviation.AppendixId == appendixId)
|
|
|
+ return new EmptyResult();
|
|
|
+
|
|
|
deviation.Site = null;
|
|
|
deviation.SiteId = null;
|
|
|
|