public HttpResponseMessage SaveDesignation(DesignationModel aDesignationModel)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = service.SaveDesignation(aDesignationModel);

                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                    else
                    {
                        string message = "Error Saving Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }
Esempio n. 2
0
 public Designation Post(Designation designation)
 {
     if (designation == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(designationService.SaveDesignation(designation.CreateFrom()).CreateFromm());
 }