public HttpResponseMessage AddUpdateProfile(AddUpworkProfileDomainModel model) { HttpResponseMessage httpResponse = new HttpResponseMessage(); try { var response = ProfileRepository.AddProfile(model); if (response == null) { httpResponse = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error Occurred"); } else if (!response.isSuccess) { httpResponse = Request.CreateResponse(HttpStatusCode.NotImplemented, response); } else { httpResponse = Request.CreateResponse(HttpStatusCode.OK, 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 AddProfile(AddUpworkProfileDomainModel model) { ResponseDomainModel resp = new ResponseDomainModel(); try { var response = objHelper.Query <ResponseDomainModel>("AddProfile", new { ProfileName = model.ProfileName, ProjectId = model.ProjectId, ProjectTypeId = model.ProjectTypeId, hourlyRate = model.hourlyRate, loggedHours = model.loggedHours, amount = model.amount, createdBy = model.createdBy }).First(); return(resp = response); } catch (SqlException sq) { ErrorLog.LogError(sq); resp.response = sq.Message; return(resp); } catch (Exception ex) { ErrorLog.LogError(ex); return(null); } }