Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,Stuff,Description")] AccountingBook accountingBook)
        {
            if (id != accountingBook.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountingBook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountingBookExists(accountingBook.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountingBook));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,UserId,Stuff,Description")] AccountingBook accountingBook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountingBook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountingBook));
        }
Esempio n. 3
0
        public IActionResult ClearCashDesk(CurrentMovementViewModel currentMovementVM)
        {
            if (currentMovementVM == null)
            {
                return(Json(new { success = false, data = "Empty data" }));
            }
            try
            {
                var claimIntetity = (ClaimsIdentity)User.Identity;
                var claim         = claimIntetity.FindFirst(ClaimTypes.NameIdentifier);

                AccountingBook accountingBook = new AccountingBook
                {
                    AccountingDate = DateTime.Now,
                    CashLeft       = currentMovementVM.cashLeft,
                    InFlowSum      = currentMovementVM.totalInflow,
                    OutFlowSum     = currentMovementVM.totalOutflow,
                    UserId         = claim.Value
                };

                _unitOfWork.AccountingBook.Add(accountingBook);
                _unitOfWork.Save();

                _unitOfWork.CurrentMovement.setAccountingBookId(accountingBook.Id);



                CurrentMovement currentMovement = new CurrentMovement()
                {
                    //AccountingBookId
                    CurrentDate  = DateTime.Now,
                    Description  = "After Cleared",
                    IsInflow     = true,
                    MovementType = CashDeskStaticValues.StaticValues().FirstOrDefault(u => u.Key == "CashDeskClearInFlow").Key,
                    Sum          = currentMovementVM.cashLeft,
                    UserId       = claim.Value,
                    Cleared      = false,
                };

                _unitOfWork.CurrentMovement.Add(currentMovement);


                _unitOfWork.Save();

                return(RedirectToAction("ClearingCashDesk"));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, data = ex.Message }));
            }
        }