Example #1
0
 public ComputerMinimal MapToBLL(ComputerEdit apiComputer)
 {
     return(new ComputerMinimal
     {
         Id = apiComputer.Id,
         Model = apiComputer.Model,
         ComputerName = apiComputer.ComputerName,
         AppUserId = apiComputer.AppUserId,
         Description = apiComputer.Description,
         IsPublic = apiComputer.IsPublic
     });
 }
        public async Task <IActionResult> PutComputer(int id, ComputerEdit computer)
        {
            if (id != computer.Id)
            {
                return(BadRequest());
            }
            computer.AppUserId = User.UserId();

            var comp = await _bll.Computers.FindAsync(id, User.UserId());

            if (comp == null && !User.IsInRole("Admin"))
            {
                return(Unauthorized(new ResponseMessage("You are not allowed to edit this entry")));
            }

            _bll.Computers.UpdateNoReturnAsync(_mapper.MapToBLL(computer));

            await _bll.SaveChangesAsync();

            return(NoContent());
        }