public LevelFunction DeleteLevelFunction(int id) { LevelFunction dbLevelFunction = context.LevelFunctions.First(lf => lf.RecordID == id); if (dbLevelFunction != null) { context.LevelFunctions.Remove(dbLevelFunction); context.SaveChanges(); } return(dbLevelFunction); }
public HttpResponseMessage PostLevelFunction([FromBody] LevelFunction levelFunction) { try { repository.SaveLevelFunction(levelFunction); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception exc) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public void SaveLevelFunction(LevelFunction levelFunction) { if (levelFunction.RecordID == 0) { context.LevelFunctions.Add(levelFunction); } else { LevelFunction dbLevelFunction = context.LevelFunctions.First(lf => lf.RecordID == levelFunction.RecordID); dbLevelFunction.FunctionID = levelFunction.FunctionID; dbLevelFunction.UserLevelID = levelFunction.UserLevelID; } context.SaveChanges(); }
public HttpResponseMessage PutLevelFunction(int id, [FromBody] LevelFunction levelFunction) { try { if (levelFunction == null) { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } repository.SaveLevelFunction(levelFunction); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception exc) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }