Exemplo n.º 1
0
        public void Install()
        {
            var directorateLevel = new Level { Id = 1, Code = "DIR", Name = "Directorate", IsActive = true, Number = 1 };
            var corporateLevel = new Level { Id = 2, Code = "COR", Name = "Corporate", IsActive = true, Number = 2 };
            var functionLevel = new Level { Id = 3, Code = "FNC", Name = "Function", IsActive = true, Number = 3 };

            _context.Levels.Add(directorateLevel);
            _context.Levels.Add(corporateLevel);
            _context.Levels.Add(functionLevel);
        }
Exemplo n.º 2
0
 public DeleteLevelResponse Delete(int id)
 {
     var response = new DeleteLevelResponse();
     try {
         var _level = new Level { Id = id};
         DataContext.Levels.Attach(_level);
         DataContext.Entry(_level).State = EntityState.Deleted;
         DataContext.SaveChanges();
         response.IsSuccess = true;
         response.Message = "Level item has been Deleted successfully";
     }
     catch (DbUpdateException dbUpdateException)
     {
         response.IsSuccess = false;
         response.Message = dbUpdateException.Message;
     }
     return response;
 }