internal static ComplaintCommentsViewModel MapComments(ComplaintComments comments) { var result = new ComplaintCommentsViewModel(); result.PreliminaryComments = Mappers.MapPreliminaryComments(comments.PreliminaryComments); result.PreliminaryDecision = Mappers.MapPreliminaryDecision(comments.PreliminaryDecisionComments); result.FinalDecision = Mappers.MapFinalDecision(comments.FinalDecisionApprovedByCurrentUser); result.FinalDecision.Document = Mappers.MapDocument(comments.FinalDecisionDocument); SetStatuses(comments.DueDate, comments.DueDaysLeft, comments.Status, result); return result; }
private ComplaintCommentsViewModel TryGetComments(int id) { var model = new ComplaintCommentsViewModel(); try { model = GetComments(id); model.AllDocuments = GetAllDocuments(id); } catch (Exception) { AddModelStateError(GlobalStrings.SomethingWentWrong); } return model; }
private static void SetStatuses(DateTime? dueDate, int? dueDays, ComplaintComments.StatusKind status, ComplaintCommentsViewModel result) { var date = dueDate ?? DateTime.Now; var days = dueDays ?? 0; result.PreliminaryComments.DueDate = date; result.PreliminaryComments.DueDays = days; result.PreliminaryDecision.DueDate = date; result.PreliminaryDecision.DueDays = days; result.FinalDecision.DueDate = date; result.FinalDecision.DueDays = days; switch (status) { case ComplaintComments.StatusKind.PreliminaryComments: SetRender(result, true, false, false); SetState(result, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess); break; case ComplaintComments.StatusKind.PreliminaryDecisionComments: SetRender(result, true, true, false); SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess); break; case ComplaintComments.StatusKind.PreliminaryDecisionWaiting: SetRender(result, true, true, false); SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.WaitingForPartiesComments, ComplaintCommentsStepState.InProcess); break; case ComplaintComments.StatusKind.FinalDecisionComments: SetRender(result, true, true, true); SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.InProcess); break; case ComplaintComments.StatusKind.FinalDecisionLocked: SetRender(result, true, true, true); SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Locked); break; case ComplaintComments.StatusKind.Complete: SetRender(result, true, true, true); SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete); break; } }
private static void SetState(ComplaintCommentsViewModel result, ComplaintCommentsStepState prelimCommentsState, ComplaintCommentsStepState prelimDecisionState, ComplaintCommentsStepState finalDecisionState) { result.PreliminaryComments.State = prelimCommentsState; result.PreliminaryDecision.State = prelimDecisionState; result.FinalDecision.State = finalDecisionState; }
private static void SetRender(ComplaintCommentsViewModel result, bool renderPrelimComments, bool renderPrelimDecision, bool renderFinalDecision) { result.RenderPreliminaryComments = renderPrelimComments; result.RenderPreliminaryDecision = renderPrelimDecision; result.RenderFinalDecision = renderFinalDecision; }