コード例 #1
0
        public async Task <ActionResult <bool> > UpdateEquipment(UpdateEquipmentRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!EquipmentStatus.IsEquipmentStatus(request.Status))
            {
                return(BadRequest("Status is not valid. Must be: " + string.Join(", ", EquipmentStatus.ListAllStatuses())));
            }

            return(await _equipmentService.UpdateEquipment(request));
        }
コード例 #2
0
 public ActionResult Update([FromBody] UpdateEquipmentRequest request)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         _equipmentService.Patch(request.Id, request.Name, request.SerialNumber, request.Status);
         return(NoContent());
     }
     catch (Exception error)
     {
         _logger.LogError(error.ToString());
         return(BadRequest());
     }
 }
コード例 #3
0
        public async Task <bool> UpdateEquipment(UpdateEquipmentRequest requestModel)
        {
            Room room = null;

            //If there's a room, check if the room exists
            if (requestModel.RoomId != null)
            {
                room = await _room.FindById(int.Parse(requestModel.RoomId));
            }

            //Get equipment from database
            var equipment = await FindById(requestModel.EquipmentId);

            //Update new information to equipment
            equipment = UpdateEquipmentRequest.UpdateToEquipment(equipment, requestModel, room);

            equipment = await _repoWrapper.Equipment.UpdateAsync(equipment, equipment.EquipmentId);

            return(true);
        }