public HttpResponseMessage AddBodyPart(Entities.MstBodyPart objBodyPart) { try { var currentUser = from d in db.MstUsers where d.AspNetUserId == User.Identity.GetUserId() select d; if (currentUser.FirstOrDefault().Id == 1) { Data.MstBodyPart newBodyPart = new Data.MstBodyPart { BodyPart = objBodyPart.BodyPart }; db.MstBodyParts.InsertOnSubmit(newBodyPart); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage UpdateBodyPart(String id, Entities.MstBodyPart objBodyPart) { try { var currentUser = from d in db.MstUsers where d.AspNetUserId == User.Identity.GetUserId() select d; if (currentUser.FirstOrDefault().Id == 1) { var bodyPart = from d in db.MstBodyParts where d.Id == Convert.ToInt32(id) select d; if (bodyPart.Any()) { var updateBodyPart = bodyPart.FirstOrDefault(); updateBodyPart.BodyPart = objBodyPart.BodyPart; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }