Пример #1
0
        public ActionResult Create(DesignationModel designationModel)
        {
            try
            {
                designationModel.RecLastUpdatedDt = DateTime.UtcNow;
                designationModel.RecLastUpdatedBy = User.Identity.GetUserId();
                // TODO: Add insert logic here
                if (designationModel.DesignationId > 0)
                {
                    designationService.UpdateDesignation(designationModel.MapClientToServer());
                }
                else
                {
                    designationModel.RecCreatedDt = DateTime.UtcNow;
                    designationModel.RecCreatedBy = User.Identity.GetUserId();

                    designationService.AddDesignation(designationModel.MapClientToServer());
                }
                TempData["message"] = new MessageViewModel
                {
                    IsSaved = true,
                    Message = "Your data has been saved successfully!"
                };
                return(RedirectToAction("Create"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Пример #2
0
 public HttpResponseMessage EditDesignation(DesignationModel aDesignationModel)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var result = service.UpdateDesignation(aDesignationModel);
             if (result != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, result));
             }
             else
             {
                 string message = "Not updated successfully";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
        public ActionResult DesignationEdit(DesignationDTO data)
        {
            ViewBag.designationList = _designationServices.GetDesignationList();
            ViewBag.levelList       = _levelService.GetLevellist();
            int reDesg = _designationServices.UpdateDesignation(data);

            ViewBag.Success = "Designation updated successfully";
            ModelState.Clear();
            return(View(data));
        }
        public ActionResult <Designation> UpdateDesignation(Designation Designation)
        {
            var d = _designationService.UpdateDesignation(Designation);

            if (d != null)
            {
                return(d);
            }
            else
            {
                return(UnprocessableEntity("Designation does not exist or Designation already exist in same department"));
            }
        }
Пример #5
0
        public object Put([FromBody] DesignationModel model)
        {
            var output = new ResponseDetail();

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.DesignationID > 0)
                    {
                        var designationDetail = Mapper.Map <Designation>(model);
                        var count             = _designationService.CheckExistingDesignation(model.DesignationName);
                        if (!count)
                        {
                            _designationService.UpdateDesignation(designationDetail);
                            output.Success = true;
                            output.Message = "Designtion updated successfully!";
                        }
                        else
                        {
                            output.Success = false;
                            output.Message = "Designtion already exists!";
                        }
                        return(output);
                    }
                    output.Success = false;
                    return(output);
                }
                output.Success = false;
                return(output);
            }
            catch (Exception ex)
            {
                output.Success = false;
                output.Message = ex.Message;
                return(output);
            }
        }
Пример #6
0
        public ActionResult UpdateDesignation(DesignationModel model)
        {
            bool flag = false;

            try
            {
                _DesignationServices.UpdateDesignation(model);
                flag = true;
            }
            catch (Exception ex)
            {
                flag = false;
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
 public HttpResponseMessage Put([FromBody] DesignationEntity DesignationEntity)
 {
     try
     {
         if (DesignationEntity.DesignationId > 0)
         {
             var result = _designation.UpdateDesignation(DesignationEntity.DesignationId, DesignationEntity);
             return(Request.CreateResponse(HttpStatusCode.OK, result));
         }
     }
     catch
     {
         throw new ApiDataException(1000, "Designation not found", HttpStatusCode.NotFound);
     }
     return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Internal Server Error"));
 }
 public IActionResult Put(int id, [FromBody] DesignationModel value)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         value.DesignationId = id;
         _designationService.UpdateDesignation(value);
         responseData.Results = _designationService.GetDesignation(id);
         responseData.Status  = "OK";
     }
     catch (Exception ex)
     {
         responseData.Status       = "Failed";
         responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
     }
     return(Ok(responseData));
 }