public HttpResponseMessage AddUpdateProject(AddUpdateProjectDomainModel model) { HttpResponseMessage httpResponse = new HttpResponseMessage(); try { if (model.HourlyRate == null) { model.HourlyRate = 0; } if (model.FixedPrice == null) { model.FixedPrice = 0; } if (!string.IsNullOrEmpty(model.StartDate)) { var sd = DateTime.ParseExact(model.StartDate, "dd/MM/yyyy", null).ToString("yyyy/MM/dd"); model.StartDate = sd; } if (!string.IsNullOrEmpty(model.EndDate)) { var ed = DateTime.ParseExact(model.EndDate, "dd/MM/yyyy", null).ToString("yyyy/MM/dd"); model.EndDate = ed; } var response = ProjectRepository.AddUpdateProject(model); if (response == null) { response.isSuccess = false; httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error Occurred"); } else if (response.response == "Success") { response.isSuccess = true; httpResponse = Request.CreateResponse(HttpStatusCode.OK, response); } else { response.isSuccess = false; httpResponse = Request.CreateResponse(HttpStatusCode.NotImplemented, response); } 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 ResponseDomainModel AddUpdateProject(AddUpdateProjectDomainModel model) { ResponseDomainModel resp = new ResponseDomainModel(); try { var response = objHelper.Query <ResponseDomainModel>("AddUpdateProjectAndEstimation", new { ProjectId = model.ProjectId, ClientId = model.ClientId, ProjectTypeId = model.ProjectTypeId, ProjectTitle = model.ProjectTitle, UploadDetailsDocument = model.UploadDetailsDocument, StartDate = model.StartDate, EndDate = model.EndDate, ProjectUrl = model.ProjectUrl, ProjectStatus = model.ProjectStatus, Archived = model.Archived, CreatedBy = model.CreatedBy, EstimateHours = model.EstimateHours.ToString(), AssignHours = model.AssignedHours.ToString(), UploadDocument = model.UploadDocument, DeveloperCodingHours = model.developerCodinghours.ToString(), WebServiceHours = model.WebserviceHours.ToString(), DesignHours = model.EstimateDesignHours.ToString(), QAHours = model.QualityAnalystHours.ToString(), HourlyRate = model.HourlyRate, FixedPrice = model.FixedPrice, CreatedDate = DateTime.Now }).First(); return(response); } catch (SqlException sq) { ErrorLog.LogError(sq); resp.response = sq.Message; return(resp); } catch (Exception ex) { ErrorLog.LogError(ex); return(null); } }