public ActionResult CancelPolicy(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entity = Uow.Policies.GetById((int)id); if (entity == null) { return(HttpNotFound()); } entity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("cancelled"); Uow.Policies.Update(entity); Uow.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { LoggingSvc.LogError(ex); return(RedirectToAction("Details", new { id = id })); } }
public ActionResult Create(ClientModel model) { try { var entity = AutoMapper.Mapper.Map <Client>(model); Uow.Clients.Add(entity); Uow.SaveChanges(); LogAdd(entity); if (string.IsNullOrEmpty(model.ReturnUrl)) { return(RedirectToAction("Index")); } else { return(Redirect(model.ReturnUrl)); } } catch (Exception ex) { LoggingSvc.LogError(ex); return(View(model)); } }
public ActionResult RenewPolicy(PolicyModel model) { try { var origEntity = Uow.Policies.GetById(model.Id); var entity = AutoMapper.Mapper.Map <Policy>(model); entity.Id = 0; entity.RenewalPolicyNumber = origEntity.PolicyNumber; entity.DateIssued = DateTime.Now; entity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("active"); origEntity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("expired"); Uow.Policies.Add(entity); Uow.Policies.Update(origEntity); Uow.SaveChanges(); return(RedirectToAction("Details", new { id = entity.Id })); } catch (Exception ex) { LoggingSvc.LogError(ex); return(RedirectToAction("Details", new { id = model.Id })); } }
public ActionResult Create(FormViewModel model, HttpPostedFileBase fileUpload) { try { SaveFile(model.NewForm, fileUpload); Form entity = AutoMapper.Mapper.Map <Form>(model.NewForm); Uow.Forms.Add(entity); Uow.SaveChanges(); //LogAdd(entity); return(RedirectToAction("Index")); } catch (Exception ex) { LoggingSvc.LogError(ex); return(RedirectToAction("Index")); } }
public ActionResult CreateAttachment(PolicyDetailModel model, HttpPostedFileBase fileUpload) { try { model.NewAttachment.PolicyId = model.Id; SaveFile(model.NewAttachment, fileUpload); PolicyAttachment entity = AutoMapper.Mapper.Map <PolicyAttachment>(model.NewAttachment); entity.PolicyId = model.Id; entity.PostedDate = DateTime.Now; Uow.PolicyAttachments.Add(entity); Uow.SaveChanges(); return(RedirectToAction("Details", "Policy", new { id = model.Id })); } catch (Exception ex) { LoggingSvc.LogError(ex); return(RedirectToAction("Details", "Policy", new { id = model.Id })); } }
public ActionResult Create(InvoiceModel model) { try { if (ModelState.IsValid == false) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } model.StatusId = AttributeProviderSvc.GetInvoiceStatusIdFromName("pending");; var entity = AutoMapper.Mapper.Map <Invoice>(model); Uow.Invoices.Add(entity); Uow.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { LoggingSvc.LogError(ex); return(View()); } }
public ActionResult EditEndorsement(PolicyDetailModel policyDetailModel, int id) { try { var model = policyDetailModel.Endt; if (model.IsRet) { model.EndorsementAmount *= -1; } var entity = AutoMapper.Mapper.Map <Endorsement>(model); Uow.Endorsements.Update(entity); UpdatePolicyAndInvoices(model); Uow.SaveChanges(); return(RedirectToAction("Details", new { id = model.PolicyId })); } catch (Exception ex) { LoggingSvc.LogError(ex); var model = policyDetailModel.Endt; return(RedirectToAction("Details", new { id = model.PolicyId })); } }