|
|
@@ -9,6 +9,7 @@ using GreenTree.Nachtragsmanagement.Services.Logging;
|
|
|
using GreenTree.Nachtragsmanagement.Services.Site;
|
|
|
using GreenTree.Nachtragsmanagement.Web.Extensions;
|
|
|
using GreenTree.Nachtragsmanagement.Web.Framework.Authorization;
|
|
|
+using GreenTree.Nachtragsmanagement.Web.Models.Appendix;
|
|
|
using GreenTree.Nachtragsmanagement.Web.Models.Deviation;
|
|
|
using GreenTree.Nachtragsmanagement.Web.Models.Global;
|
|
|
using Newtonsoft.Json;
|
|
|
@@ -187,10 +188,10 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
foreach (var column in e.ColumnsInfo)
|
|
|
{
|
|
|
if (column.FieldName == "CustomNumber") { column.ColumnWidth = 30; }
|
|
|
+ if (column.FieldName == "Description") { column.IsVisible = false; column.IsDetail = true; }
|
|
|
if (column.FieldName == "SiteDescription") { column.ColumnWidth = 60; }
|
|
|
if (column.FieldName == "AppendixDescription") { column.ColumnWidth = 50; }
|
|
|
if (column.FieldName == "StatusDescription") { column.ColumnWidth = 60; }
|
|
|
- if (column.FieldName == "Comment") { column.IsVisible = false; column.IsDetail = true; }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -322,6 +323,76 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
return PartialView("~/Views/Deviations/_DeviationEditPartial.cshtml", deviationModel);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Partial Edit result for assigning a deviation to a new appendix
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id">Id of deviation.</param>
|
|
|
+ public ActionResult AssignDeviationToAppendix(int id)
|
|
|
+ {
|
|
|
+ var deviation = _deviationService.GetDeviationById(id);
|
|
|
+ var availableAppendices = new List<Appendix>();
|
|
|
+
|
|
|
+ if (deviation.Site != null)
|
|
|
+ availableAppendices.AddRange(
|
|
|
+ deviation.Site.Appendices);
|
|
|
+ else if (deviation.Appendix != null && deviation.Appendix.Site != null)
|
|
|
+ {
|
|
|
+ availableAppendices.AddRange(
|
|
|
+ deviation.Appendix.Site.Appendices
|
|
|
+ .Where(a => a.Id != deviation.AppendixId));
|
|
|
+ }
|
|
|
+
|
|
|
+ var appendixModels = availableAppendices
|
|
|
+ .Select(a => AppendixDataModel.FromAppendix(a, false))
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ if (deviation.Appendix != null && deviation.Appendix.Site != null)
|
|
|
+ appendixModels.Insert(0, new AppendixDataModel { Id = -1, Description = "Keinem (Als \"Offen\" markieren)" });
|
|
|
+
|
|
|
+ ViewData["DeviationId"] = id;
|
|
|
+
|
|
|
+ return PartialView("~/Views/Deviations/_DeviationAssignPartial.cshtml", appendixModels);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Assigns a deviation to the specified appendix
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id">Id of deviation.</param>
|
|
|
+ [HttpPost]
|
|
|
+ public ActionResult AssignDeviation(int id, int appendixId)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var deviation = _deviationService.GetDeviationById(id);
|
|
|
+
|
|
|
+ if (appendixId == -1 && deviation.Appendix != null && deviation.Appendix.Site != null)
|
|
|
+ {
|
|
|
+ deviation.SiteId = deviation.Appendix.SiteId;
|
|
|
+ deviation.Appendix = null;
|
|
|
+ deviation.AppendixId = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ deviation.AppendixId = appendixId;
|
|
|
+ deviation.Site = null;
|
|
|
+ deviation.SiteId = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ _deviationService.UpdateDeviation(deviation);
|
|
|
+
|
|
|
+ return new JsonResult
|
|
|
+ {
|
|
|
+ Data = "success"
|
|
|
+ };
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _logger.Error("Fehler bei Zuweisung einer Vertragsabweichung zu einem Nachtrag.", ex, _userHelper.FromCookies());
|
|
|
+
|
|
|
+ return PartialView("~/Views/Shared/_PopupError.cshtml", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Partial edit result if ModelState is valid, otherwise simple JSON result for success
|
|
|
/// </summary>
|