Esempio n. 1
0
        public async Task <IActionResult> returnBook(string code)
        {
            try {
                code = Encoding.UTF8.GetString(Convert.FromBase64String(code));
                int borrow_id = Convert.ToInt32(code.Substring(6));

                Borrow borrow = await _borrowRepository.Get(borrow_id);

                var  username = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                User user     = await _userRepository.FindByUsername(username);

                if (user == null)
                {
                    return(NotFound(new Respone(404, "Not Found", null)));
                }

                if (user.user_id != borrow.user_id_borrow)
                {
                    return(BadRequest(new Respone(400, "Failed", null)));
                }

                borrow.return_date = DateTime.Now;

                await _borrowRepository.Update(borrow_id, borrow);

                return(Ok(new Respone(200, "ok", null)));
            } catch (Exception e) {
                return(BadRequest(new Respone(400, "Failed", null)));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新借出归还信息
        /// </summary>
        /// <param name="returnDto"></param>
        public void AssetsReturn(ReturnDto returnDto)
        {
            var borrow = _borrowRep.Find(returnDto.BorrowId);

            if (null == borrow)
            {
                throw new Exception("未找到对应的借用记录");
            }
            if (borrow.HasReturn > 0)
            {
                throw new Exception("已经归还");
            }
            borrow.ReturnPerson = returnDto.ReturnPerson;
            borrow.ReturnDate   = returnDto.ReturnDate;
            borrow.ReturnMome   = returnDto.ReturnMome;
            borrow.HasReturn    = 1;
            _borrowRep.Update(borrow);
            foreach (var statu in returnDto.AssetsStatus)
            {
                var detail =
                    _borrowDetailRep.FirstOrDefault(d => d.BorrowFormNo == borrow.EntityId && d.AssetsNo == statu.Key);
                if (null != detail)
                {
                    detail.ReturnStatus = statu.Value;
                    _borrowDetailRep.Update(detail);
                }
            }
            //清空使用人
            _assetsMainRep.UpdateUsePeople("", returnDto.AssetsStatus.Select(x => x.Key).ToList());
        }
        public async Task Update(BorrowDto borrow)
        {
            Borrow entity = BorrowMapper.MapDtoToBorrow(borrow);

            entity.Movie = await _iMovieRepository.GetById(borrow.MovieId.GetValueOrDefault());

            entity.Client = await _iClientRepository.GetById(borrow.ClientId.GetValueOrDefault());

            await _iBorrowRepository.Update(entity);
        }
Esempio n. 4
0
        public void Update(BorrowDTO recDTO)
        {
            Borrow borrow = _borrowRepository.Find(recDTO.BookID, recDTO.StudentID);

            if (borrow == null)
            {
                throw new DataException(string.Format(ValidationConstants.SDataNotFoundWithValue, "Borrow", string.Format("book: {0} student: {1}", recDTO.BookID, recDTO.StudentID)));
            }

            borrow = BorrowMapper.Map(recDTO);
            _borrowRepository.Update(borrow);
        }
Esempio n. 5
0
        public async Task Update(Guid borrowId, DateTime returnDate, string status)
        {
            var borrow = await _borrowRepository.Get(borrowId);

            if (borrow == null)
            {
                return;
            }

            borrow.SetReturnDate(returnDate);
            borrow.SetStatus(status);

            await _borrowRepository.Update(borrow);
        }
Esempio n. 6
0
        public IActionResult Delete(int borrowId)
        {
            try
            {
                var borrow = _borrowRepository.GetSingleByCondition(b => b.Id == borrowId && b.IsDeleted == false && b.Status == false);

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

                borrow.IsDeleted = true;
                borrow.UpdatedBy = User.Identity.Name;
                borrow.UpdatedOn = DateTime.Now;

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