public HttpResponseMessage SaveMstModel(MstModel model) { try { var editModels = from d in db.MstModels where d.Id == Convert.ToInt32(model.Id) select d; if (editModels.Any()) { var editModel = editModels.FirstOrDefault(); editModel.FullName = model.FullName; editModel.Description = model.Description; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.OK)); } } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public Int32 PostMstModel(MstModel model) { try { Data.MstModel newModel = new Data.MstModel() { FullName = model.FullName, Description = model.Description }; db.MstModels.InsertOnSubmit(newModel); db.SubmitChanges(); return(newModel.Id); } catch (Exception e) { return(0); } }