public ComponentInComputerMinimal MapToBLL(ComponentInComputerEdit apiComponentInComputer)
 {
     return(new ComponentInComputerMinimal()
     {
         Id = apiComponentInComputer.Id,
         AppUserId = apiComponentInComputer.AppUserId,
         ComponentId = apiComponentInComputer.ComponentId,
         ComputerId = apiComponentInComputer.ComputerId,
         Notice = apiComponentInComputer.Notice
     });
 }
示例#2
0
        public async Task <IActionResult> PutComponentInComputer(int id, ComponentInComputerEdit componentInComputer)
        {
            if (id != componentInComputer.Id)
            {
                return(BadRequest());
            }

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

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

            componentInComputer.AppUserId = User.UserId();

            _bll.ComponentInComputers.UpdateNoReturnAsync(_mapper.MapToBLL(componentInComputer));

            await _bll.SaveChangesAsync();

            return(NoContent());
        }