public ActionResult Create(Designation obj)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var result = iDesignation.Update(obj, "i");
                    return(Json(new
                    {
                        ErrorCode = result.ErrorCode,
                        Message = result.Msg,
                        Id = result.Id,
                        JsonRequestBehavior.AllowGet
                    }));
                }
                catch (Exception ex)
                {
                    return(Json(new { ErrorCode = 1, Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            Response.TrySkipIisCustomErrors = true;
            string messages = string.Join("; ", ModelState.Values
                                          .SelectMany(x => x.Errors)
                                          .Select(x => x.ErrorMessage));

            return(Json(new { ErrorCode = 1, Message = messages }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 public ActionResult Edit(Designation designation)
 {
     if (ModelState.IsValid)
     {
         var model = designationService.Find(designation.Id);
         model.DesignationName = designation.DesignationName;
         designationService.Update(model);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
 public JsonResult Save([Bind(Include = "Id,Name,Description,IsActive")] DesignationModel designation, bool isInsert)
 {
     if (isInsert)
     {
         designation.SetCreateProperties(LoginInformation.UserInformation.Id);
         designation.Id = _designationService.Insert(designation);
     }
     else
     {
         designation.SetUpdateProperties(LoginInformation.UserInformation.Id);
         _designationService.Update(designation);
     }
     return(new JsonResult {
         Data = designation
     });
 }
Exemple #4
0
        public ActionResult DesignationUpdate(Designation designation)

        {
            _designationService.Update(designation);
            return(RedirectToAction(""));
        }
Exemple #5
0
        public ActionResult Post(Designation vm)
        {
            Designation pt = vm;

            if (ModelState.IsValid)
            {
                if (vm.DesignationId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _DesignationService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

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

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Designation).DocumentTypeId,
                        DocId        = pt.DesignationId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create").Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    Designation temp = _DesignationService.Find(pt.DesignationId);

                    Designation ExRec = Mapper.Map <Designation>(temp);

                    temp.DesignationName = pt.DesignationName;
                    temp.IsActive        = pt.IsActive;
                    temp.ModifiedDate    = DateTime.Now;
                    temp.ModifiedBy      = User.Identity.Name;
                    temp.ObjectState     = Model.ObjectState.Modified;
                    _DesignationService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Designation).DocumentTypeId,
                        DocId           = temp.DesignationId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }

            return(View("Create", vm));
        }