public HttpResponseMessage SaveSysDropDown(SysDropDown dropDown) { try { var SysDropDowns = from d in db.SysDropDowns where d.Id == Convert.ToInt32(dropDown.Id) select d; if (SysDropDowns.Any()) { var updateSysDropDowns = SysDropDowns.FirstOrDefault(); updateSysDropDowns.Category = dropDown.Category; updateSysDropDowns.Description = dropDown.Description; updateSysDropDowns.Value = dropDown.Value; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.OK)); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public Int32 PostSysDropDown(SysDropDown dropDown) { try { Data.SysDropDown newSysDropDown = new Data.SysDropDown() { Category = dropDown.Category, Description = dropDown.Description, Value = dropDown.Value }; db.SysDropDowns.InsertOnSubmit(newSysDropDown); db.SubmitChanges(); return(newSysDropDown.Id); } catch (Exception e) { Debug.WriteLine(e); return(0); } }