Esempio n. 1
0
        public HttpResponseMessage AddUpdateReportCategory(ProjectReportCategoryDomainModel model)
        {
            HttpResponseMessage httpResponse = new HttpResponseMessage();

            try
            {
                var objRes = ProjectRepository.AddUpdateReportCategory(model);
                if (objRes == null)
                {
                    httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error Occurred");
                }
                else
                {
                    httpResponse = Request.CreateResponse(HttpStatusCode.OK, 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 AddUpateProjectTaskCategories(ProjectReportCategoryDomainModel model)
 {
     if (model != null)
     {
         model.CreatedBy   = UserManager.user.UserId;
         model.CreatedDate = DateTime.Now;
         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/Project/AddUpdateReportCategory", content).Result;
         if (result.StatusCode == HttpStatusCode.OK)
         {
             var contents = result.Content.ReadAsStringAsync().Result;
             var Response = new JavaScriptSerializer().Deserialize <ResponseModel>(contents);
         }
     }
     return(RedirectToAction("_ProjectTaskCategories"));
 }
        public ResponseDomainModel AddUpdateReportCategory(ProjectReportCategoryDomainModel model)
        {
            ResponseDomainModel objRes = new ResponseDomainModel();

            try
            {
                var CategoryId = objHelper.ExecuteScalar("AddUpdateReportCategory", new
                {
                    CategoryId   = model.CategoryId,
                    DepartmentId = model.DepartmentId,
                    CategoryName = model.CategoryName,
                    IsActive     = model.IsActive,
                    CreatedDate  = model.CreatedDate,
                    CreatedBy    = model.CreatedBy
                });
                if (model.CategoryId > 0)
                {
                    objRes.isSuccess = true;
                    objRes.response  = "Category updated successfully.";
                }
                else if (CategoryId > 0)
                {
                    objRes.isSuccess = true;
                    objRes.response  = "Category added successfully.";
                }
                else
                {
                    objRes.isSuccess = false;
                    objRes.response  = "Something went wrong, please try again.";
                }
                return(objRes);
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(null);
            }
        }