Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public HttpResponseMessage PostLevelFunction([FromBody] LevelFunction levelFunction)
 {
     try
     {
         repository.SaveLevelFunction(levelFunction);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception exc)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
Esempio n. 3
0
 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();
 }
Esempio n. 4
0
 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));
     }
 }