// GET: Project
 public ActionResult AddUpdateProject(int ProjectId = 0)
 {
     ViewBag.Class = "display-hide";
     GetProjectTypeAndClients();
     try
     {
         if (ProjectId > 0)
         {
             var client = new HttpClient();
             client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
             var Clientresult = client.GetAsync(BaseURL + "/api/Project/GetProjectDetailsById?ProjectId=" + ProjectId).Result;
             if (Clientresult.StatusCode == HttpStatusCode.OK)
             {
                 var contents = Clientresult.Content.ReadAsStringAsync().Result;
                 var response = new JavaScriptSerializer().Deserialize <GetProjectByIdModel>(contents);
                 var a        = string.IsNullOrEmpty(response.EstimateHours) ? (decimal?)null : Convert.ToDecimal(response.EstimateHours);
                 AddUpdateProjectModel model = new AddUpdateProjectModel()
                 {
                     ProjectId             = response.ProjectId,
                     ClientId              = response.ClientId,
                     ProjectTypeId         = response.ProjectTypeId,
                     ProjectTitle          = response.ProjectTitle,
                     ProjectUrl            = response.ProjectUrl,
                     HourlyRate            = response.HourlyRate,
                     FixedPrice            = response.FixedPrice,
                     UploadDocument        = response.UploadDocument,
                     StartDate             = response.StartDate,
                     EndDate               = response.EndDate,
                     EstimateHours         = string.IsNullOrEmpty(response.EstimateHours) ? 0 : Convert.ToDecimal(response.EstimateHours),
                     AssignedHours         = string.IsNullOrEmpty(response.AssignHours) ? (decimal?)null : Convert.ToDecimal(response.AssignHours),
                     developerCodinghours  = string.IsNullOrEmpty(response.DeveloperCodingHours) ? (decimal?)null : Convert.ToDecimal(response.DeveloperCodingHours),
                     WebserviceHours       = string.IsNullOrEmpty(response.WebServiceHours) ? (decimal?)null : Convert.ToDecimal(response.WebServiceHours),
                     EstimateDesignHours   = string.IsNullOrEmpty(response.DesignHours) ? (decimal?)null : Convert.ToDecimal(response.DesignHours),
                     SEOHours              = string.IsNullOrEmpty(response.SEOHours) ? (decimal?)null : Convert.ToDecimal(response.SEOHours),
                     MaintainenceHours     = string.IsNullOrEmpty(response.MaintainenceHours) ? (decimal?)null : Convert.ToDecimal(response.MaintainenceHours),
                     NetworkSupportHours   = string.IsNullOrEmpty(response.NetworkSupprotHours) ? (decimal?)null : Convert.ToDecimal(response.NetworkSupprotHours),
                     QualityAnalystHours   = string.IsNullOrEmpty(response.QAHours) ? (decimal?)null : Convert.ToDecimal(response.QAHours),
                     UploadDetailsDocument = response.UploadDetailsDocument
                 };
                 return(View(model));
             }
             else
             {
                 ViewBag.Class   = "alert-danger";
                 ViewBag.Message = "Error Occurred";
             }
         }
         return(View());
     }
     catch (Exception ex)
     {
         ViewBag.Class   = "alert-danger";
         ViewBag.Message = ex.Message;
         return(View());
     }
 }
 public ActionResult AddUpdateProject(AddUpdateProjectModel model)
 {
     ViewBag.Class   = "alert-danger";
     ViewBag.Message = "Added Successfully";
     GetProjectTypeAndClients();
     try
     {
         if (ModelState.IsValid)
         {
             model.CreatedBy = UserManager.user.UserId;
             if (model.UploadDetailsDocumentFile != null && model.UploadDetailsDocumentFile.ContentLength > 0)
             {
                 var uniqueName = Guid.NewGuid();
                 model.UploadDetailsDocument = uniqueName + model.UploadDetailsDocumentFile.FileName;
                 model.UploadDetailsDocumentFile.SaveAs(Server.MapPath("~/UploadDocuments/" + model.UploadDetailsDocument));
                 model.UploadDetailsDocumentFile = null; // do null nor it will cause error while serializing
             }
             if (model.UploadDocumentFile != null && model.UploadDocumentFile.ContentLength > 0)
             {
                 var uniqueName = Guid.NewGuid();
                 model.UploadDocument = uniqueName + model.UploadDocumentFile.FileName;
                 model.UploadDocumentFile.SaveAs(Server.MapPath("~/UploadDocuments/" + model.UploadDocument));
                 model.UploadDocumentFile = null; // do null nor it will cause error while serializing
             }
             model.ProjectStatus = "Open";
             model.Archived      = "NonArchive";
             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 Clientresult = client.PostAsync(BaseURL + "/api/Project/AddUpdateProject", content).Result;
             if (Clientresult.StatusCode == HttpStatusCode.OK)
             {
                 ViewBag.Class = "alert-success";
                 if (model.ProjectId > 0)
                 {
                     ViewBag.Message = "Updated Successfully";
                 }
                 var contents = Clientresult.Content.ReadAsStringAsync().Result;
                 var response = new JavaScriptSerializer().Deserialize <ResponseModel>(contents);
                 ModelState.Clear();
             }
             else if (Clientresult.StatusCode == HttpStatusCode.NotImplemented)
             {
                 var contents = Clientresult.Content.ReadAsStringAsync().Result;
                 var response = new JavaScriptSerializer().Deserialize <ResponseModel>(contents);
                 ViewBag.Message = response.response;
             }
             else
             {
                 ViewBag.Message = "Error Occurred";
             }
         }
         else
         {
             ViewBag.Message = "Error Occurred";
         }
         return(View());
     }
     catch (Exception ex)
     {
         ViewBag.Message = "Error Occurred";
         return(View());
     }
 }