Example #1
0
        public ActionResult DeleteConfirmed(ReasonViewModel vm)
        {
            if (ModelState.IsValid)
            {
                //Commit the DB
                try
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    PersonRateGroup temp      = _PersonRateGroupService.Find(vm.id);
                    int             DocTypeId = (int)temp.DocTypeId;

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = Mapper.Map <PersonRateGroup>(temp),
                    });

                    XElement Modifications = _modificationCheck.CheckChanges(LogList);

                    _PersonRateGroupService.Delete(vm.id);

                    _logger.LogActivityDetail(logVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = DocTypeId,
                        DocId           = temp.PersonRateGroupId,
                        ActivityType    = (int)ActivityTypeContants.Deleted,
                        UserRemark      = vm.Reason,
                        DocNo           = temp.PersonRateGroupName,
                        xEModifications = Modifications,
                        DocDate         = temp.CreatedDate,
                    }));
                }


                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    TempData["CSEXC"] += message;
                    return(PartialView("_Reason", vm));
                }



                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }
        public ActionResult DeleteConfirmed(ReasonViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            if (ModelState.IsValid)
            {
                var temp = _PersonRateGroupService.Find(vm.id);

                LogList.Add(new LogTypeViewModel
                {
                    ExObj = temp,
                });

                _PersonRateGroupService.Delete(vm.id);
                XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);
                try
                {
                    _unitOfWork.Save();
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    ModelState.AddModelError("", message);
                    return(PartialView("_Reason", vm));
                }

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId       = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.PersonRateGroup).DocumentTypeId,
                    DocId           = temp.PersonRateGroupId,
                    ActivityType    = (int)ActivityTypeContants.Deleted,
                    UserRemark      = vm.Reason,
                    xEModifications = Modifications,
                }));

                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }