public HttpResponseMessage PostExpertDetail(object ExpertDetailobj) { JavaScriptSerializer js = new JavaScriptSerializer(); var json = ExpertDetailobj; ExpertDetail expertDetail = js.Deserialize <ExpertDetail>(json.ToString()); if (ModelState.IsValid) { ExpertDetailRepository.Add(expertDetail); unitOfWork.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, expertDetail); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = expertDetail.ExpertDetailId })); return(response); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public HttpResponseMessage Delete(int id) { ExpertDetail expertDetail = ExpertDetailRepository.Get(t => t.ExpertDetailId == id); if (expertDetail == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } ExpertDetailRepository.Delete(expertDetail); try { unitOfWork.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, expertDetail)); }
public ExpertDetail Get(int id) { return(ExpertDetailRepository.Get(t => t.UserId == id)); }
public IEnumerable <ExpertDetail> GetExpertDetails() { return(ExpertDetailRepository.GetAll()); }