Exemplo n.º 1
0
        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 }));
            }
        }
Exemplo n.º 2
0
        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 }));
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, PolicyModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                    return(View(policyDetailModel));
                }

                model.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName(model.StatusName);

                var entity = AutoMapper.Mapper.Map <Policy>(model);
                Uow.Policies.Update(entity);
                Uow.SaveChanges();

                if (string.IsNullOrEmpty(model.ReturnUrl) == false)
                {
                    return(Redirect(model.ReturnUrl));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                return(View(policyDetailModel));
            }
        }