Example #1
0
        public IActionResult Put(int deviceId)
        {
            try
            {
                var borrow = _borrowRepository.GetSingleByCondition(b => b.IsDeleted == false && b.DeviceId == deviceId && b.Status == true);

                if (borrow == null)
                {
                    return(NotFound());
                }

                borrow.ReturnOn = DateTime.Now;
                borrow.Status   = false;

                _borrowRepository.UpdateAndNotSave(borrow);

                var device = _deviceRepository.GetById(deviceId);

                device.IsBorrowed = false;

                _deviceRepository.UpdateAndNotSave(device);

                _unitOfWork.Commit();

                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }