Example #1
0
 public HttpResponseMessage GetDesignationsBasedOnRole(long DepartmentId)
 {
     try
     {
         HttpResponseMessage    httpResponse = new HttpResponseMessage();
         DesignationDomainModel objRes       = new DesignationDomainModel();
         objRes.listDesignations = managementRepository.GetDesignationsBasedOnRole(DepartmentId);
         if (objRes.listDesignations != null)
         {
             objRes.isSuccess = true;
             objRes.response  = "Success";
             httpResponse     = Request.CreateResponse(HttpStatusCode.OK, objRes);
         }
         else
         {
             httpResponse = Request.CreateResponse(HttpStatusCode.Unauthorized, objRes);
         }
         return(httpResponse);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content      = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "An error occurred, please try again or contact the administrator.",
             StatusCode   = HttpStatusCode.InternalServerError
         });
     }
 }
 public ActionResult AddUpdateDesignation(DesignationDomainModel model)
 {
     if (model != null)
     {
         if (UserManager.user.roleType == roleTypeModel.TeamLeader)
         {
             model.DepartmentId = UserManager.user.DepartmentId;
         }
         var serialized = new JavaScriptSerializer().Serialize(model);
         var client     = new HttpClient();
         var content    = new StringContent(serialized, System.Text.Encoding.UTF8, "application/json");
         client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
         var result = client.PostAsync(BaseURL + "/api/Management/AddupdateDesignation", content).Result;
         if (result.StatusCode == HttpStatusCode.OK)
         {
             var contents = result.Content.ReadAsStringAsync().Result;
             var Response = new JavaScriptSerializer().Deserialize <ResponseModel>(contents);
         }
     }
     return(RedirectToAction("_Designations"));
 }
Example #3
0
 public HttpResponseMessage AddupdateDesignation(DesignationDomainModel model)
 {
     try
     {
         HttpResponseMessage httpResponse = new HttpResponseMessage();
         ResponseDomainModel res          = new ResponseDomainModel();
         if (model != null && !string.IsNullOrWhiteSpace(model.DesignationName))
         {
             res = managementRepository.AddUpdateDesignation(model);
             if (res != null && res.isSuccess)
             {
                 httpResponse = Request.CreateResponse(HttpStatusCode.OK, res);
             }
             else
             {
                 httpResponse = Request.CreateResponse(HttpStatusCode.Unauthorized, res);
             }
         }
         else
         {
             res.isSuccess = false;
             res.response  = "Please enter designation name";
             httpResponse  = Request.CreateResponse(HttpStatusCode.Unauthorized, res);
         }
         return(httpResponse);
     }
     catch (Exception ex)
     {
         ErrorLog.LogError(ex);
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content      = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "An error occurred, please try again or contact the administrator.",
             StatusCode   = HttpStatusCode.InternalServerError
         });
     }
 }