Example #1
0
 public IActionResult CreateTask([FromQuery] TaskViewModels model)
 {
     try
     {
         context.Tasks.Add(_mapper.Map <Tasks>(model));
         context.SaveChanges();
         return(Ok(new ResponseModels {
             Success = true, Message = "Create task succeed"
         }));
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
         return(StatusCode(500, new ResponseModels {
             Success = false, Message = "Something went wrong"
         }));
     }
 }
        public IActionResult RemoveFromGroup(int userID)
        {
            try
            {
                var emp = _context.Users.FirstOrDefault(q => q.Id == userID);

                emp.GroupId = 0;

                _context.Users.Update(emp);

                _context.SaveChanges();

                return(Ok(new ResponseModels {
                    Success = true, Message = "Remove succeed"
                }));
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
                return(StatusCode(500, new ResponseModels {
                    Message = "", Success = false
                }));
            }
        }