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)); }
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()); } }
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); }