Exemplo n.º 1
0
        public BooksInViewModel Add(BooksInViewModel booksInViewModel)
        {
            var book = Mapper.Map <BooksInViewModel, BooksIn>(booksInViewModel);

            _booksInRepository.Add(book);
            _unitOfWork.Commit();
            return(booksInViewModel);
        }
Exemplo n.º 2
0
        public IActionResult SaveEntity(List <BooksInDetailViewModel> listBooksInDetailVms)
        {
            var bookVm = new BooksInViewModel();
            var userid = _generalFunctionController.Instance.getClaimType(User, CommonConstants.UserClaims.Key);
            var model  = new MerchantViewModel();

            if (Guid.TryParse(userid, out var guid))
            {
                model = _merchantService.GetBysId(userid);
            }
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(allErrors));
            }
            else
            {
                if (model != null)
                {
                    bookVm.MerchantFK = model.KeyId;
                    _booksInService.Add(bookVm);
                    _booksInService.Save();
                    var booksInFK = _booksInService.GetLastest();
                    foreach (var i in listBooksInDetailVms)
                    {
                        i.BooksInFK = booksInFK;
                        _booksInDetailService.Add(i);
                        _bookService.UpdateBookQtyByBooksIn(i.BookFK, i.Qty);
                    }
                    _booksInDetailService.Save();
                    return(new OkObjectResult(bookVm));
                }
                else
                {
                    return(new BadRequestResult());
                }
            }
        }
Exemplo n.º 3
0
 public void Update(BooksInViewModel BookViewModel)
 {
     throw new NotImplementedException();
 }