Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Name,Value")] PatternSMS patternSMS)
        {
            if (ModelState.IsValid)
            {
                _context.Add(patternSMS);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(patternSMS));
        }
        public async Task <IActionResult> Create([Bind("Id,Value")] PatternSMS patternSMS)
        {
            if (ModelState.IsValid)
            {
                patternSMS.ID = Guid.NewGuid();
                _context.Add(patternSMS);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(PatternSMS)));
            }
            return(View(patternSMS));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,UserID,PatternSMSID,Balance,PaymentType")] Wallet wallet)
        {
            if (ModelState.IsValid)
            {
                wallet.UserID = _userManager.GetUserId(User);
                _context.Add(wallet);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PatternSMSDropDownList();
            return(View(wallet));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ID,INN,Name,Address,OperationTypeID")] Account account)
        {
            //account.OperationType = _context.OperationType.SingleOrDefault(o => o.ID == account.OperationTypeID);
            if (ModelState.IsValid)
            {
                _context.Add(account);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OperationTypeID"] = new SelectList(_context.OperationType, "ID", "Name", account.OperationTypeID);
            return(View(account));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ID,Name,Color,Icon")] OperationType operationType)
        {
            if (ModelState.IsValid)
            {
                operationType.ID = Guid.NewGuid();
                _context.Add(operationType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }



            return(View(operationType));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> AddReciept([Bind("ID,WalletID,FN,FD,FP")] Accounting accounting)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accounting);


                if (accounting.FD != null && accounting.FN != null && accounting.FP != null)
                {
                    NalogData data = new NalogData();
                    string    json = await data.GetReceiptAsinch(accounting.FD, accounting.FN, accounting.FP);

                    accounting.RecieptJSON = json;
                    Receipt rec = ReceiptToClass.FromJson(json).Document.Receipt;
                    IQueryable <Account> accQuery = (from a in _context.Accounts
                                                     where a.INN == Convert.ToInt64(rec.UserInn)
                                                     select a);
                    if (accQuery.Count() > 0)
                    {
                        accounting.Account         = accQuery.First();
                        accounting.OperationTypeID = accQuery.First().OperationTypeID;
                    }
                    else
                    {
                        Account lAcc = new Account()
                        {
                            ID              = new Guid(),
                            INN             = Convert.ToInt64(rec.UserInn),
                            Name            = rec.User,
                            Address         = rec.RetailPlaceAddress,
                            OperationTypeID = _context.OperationType.Where(o => o.Name == "default").Select(o => o.ID).First()
                        };
                        _context.Update(lAcc);
                        accounting.Account         = lAcc;
                        accounting.OperationTypeID = _context.OperationType.Where(o => o.Name == "default").Select(o => o.ID).First();
                    }

                    accounting.Summ = rec.TotalSum / 100;
                    accounting.DateTimeOperation = rec.DateTime.DateTime;
                    accounting.AccountingType    = AccountingTypes.Expense;
                    accounting.Currency          = Currencyes.rub;
                }

                if (accounting.Summ != null && accounting.Summ.Value > 0)
                {
                    decimal sum    = accounting.Summ.Value;
                    Wallet  wallet = (from w in _context.Wallets
                                      where w.ID == accounting.WalletID &&
                                      w.UserID == _userManager.GetUserId(User)
                                      select w).First();
                    if (accounting.AccountingType == 0)
                    {
                        wallet.Balance = wallet.Balance + sum;
                    }
                    else
                    {
                        wallet.Balance = wallet.Balance - sum;
                    }
                    _context.Update(wallet);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(accounting));
        }