private Models.Job._DateChangeModel UpdateInsuranceClaimFormSentDate(Job job, string ClaimFormSentDate) { // Validate Is NonWarranty Job if (!job.JobTypeId.Equals(JobType.JobTypeIds.HNWar, StringComparison.OrdinalIgnoreCase)) { throw new Exception("This property can only be set for Hardware NonWarranty Jobs"); } if (string.IsNullOrEmpty(ClaimFormSentDate)) { job.JobMetaInsurance.ClaimFormSentDate = null; } else { if (ClaimFormSentDate.Equals("Now", StringComparison.OrdinalIgnoreCase)) { job.JobMetaInsurance.ClaimFormSentDate = DateTime.Now; } else { DateTime d; if (DateTime.TryParse(ClaimFormSentDate, out d)) { d = job.ValidateDateAfterOpened(d); job.JobMetaInsurance.ClaimFormSentDate = d; } else { throw new Exception("Invalid Date Format"); } } } job.JobMetaInsurance.ClaimFormSentUserId = CurrentUser.UserId; Database.SaveChanges(); return new Models.Job._DateChangeModel() { Id = job.Id, Result = "OK", UserDescription = CurrentUser.ToString() }.SetDateTime(job.JobMetaInsurance.ClaimFormSentDate); }
private void UpdateExpectedClosedDate(Job job, string ExpectedClosedDate) { if (!string.IsNullOrEmpty(ExpectedClosedDate)) { DateTime ecd; if (DateTime.TryParse(ExpectedClosedDate, out ecd)) { ecd = job.ValidateDateAfterOpened(ecd); job.ExpectedClosedDate = ecd; } else { throw new Exception("Invalid Date Format"); } } else { job.ExpectedClosedDate = null; } Database.SaveChanges(); }