Ejemplo n.º 1
0
        public IActionResult Create(SupplierAccountViewModel model)
        {
            var supplierAccount = _mapper.Map <SupplierAccount>(model);

            supplierAccount.CreatedDate = DateTime.Now;
            supplierAccount.Status      = 1;

            var supplierAccountOwnCheques        = new List <SupplierAccountOwnCheque>();
            var supplierAccountThirdPartyCheques = new List <SupplierAccountThirdPartyCheque>();

            model.OwnChequesId.ForEach(item => {
                supplierAccountOwnCheques.Add(new SupplierAccountOwnCheque()
                {
                    OwnChequeId = item
                });
            });
            model.ThirdPartyChequesId.ForEach(item => {
                supplierAccountThirdPartyCheques.Add(new SupplierAccountThirdPartyCheque()
                {
                    ThirdPartyChequeId = item
                });
            });

            supplierAccount.SupplierAccountOwnCheques        = supplierAccountOwnCheques;
            supplierAccount.SupplierAccountThirdPartyCheques = supplierAccountThirdPartyCheques;

            _context.SupplierAccounts.Add(supplierAccount);
            var flag   = _context.SaveChanges();
            var lastId = supplierAccount.SupplierAccountId;

            return(Ok(flag > 0));
        }
Ejemplo n.º 2
0
        public IActionResult SupplierAccountDetailView(string breadCumValue, long supAccId)
        {
            if (HttpContext.Session.GetString("loggedIn") == null || HttpContext.Session.GetString("loggedIn") == "false")
            {
                return(RedirectToAction("Index", "Login"));
            }
            ViewBag.breadCumValue = breadCumValue;
            ViewBag.IsUpdate      = supAccId > 0 ? "true" : "false";

            SupplierAccountViewModel supplierAccountViewModel = new SupplierAccountViewModel();

            if (supAccId > 0)
            {
                supplierAccountViewModel = (from a in _context.SupplierAccounts where a.SupplierAccountId == supAccId
                                            select new SupplierAccountViewModel {
                    SupplierAccountId = a.SupplierAccountId, Description = a.Description, Amount = a.Amount, AccountType = a.AccountType,
                    CreatedDate = a.CreatedDate, Remark = a.Remark, SupplierId = a.SupplierId, CreatedBy = a.CreatedBy, Date = a.Date,
                    OwnChequesId = a.SupplierAccountOwnCheques.Select(x => x.OwnChequeId).ToList(),
                    ThirdPartyChequesId = a.SupplierAccountThirdPartyCheques.Select(x => x.ThirdPartyChequeId).ToList()
                }).Single();
            }

            supplierAccountViewModel.SupplierList = _context.Customers.Where(s => s.CurrentStatus == 1).Select(x => new Supplier()
            {
                SupplierId = x.CustomerId, SupplierName = x.CustomerName
            }).ToList();
            supplierAccountViewModel.OwnChequesList = _context.OwnCheques.Select(x => new OwnCheque()
            {
                OwnChequeId = x.OwnChequeId, ChequeCode = x.ChequeCode, Amount = x.Amount
            }).ToList();
            supplierAccountViewModel.ThirdPartyChequesList = _context.ThirdPartyCheques.Select(x => new ThirdPartyCheque()
            {
                ThirdPartyChequeId = x.ThirdPartyChequeId, ChequeCode = x.ChequeCode, Amount = x.Amount
            }).ToList();

            return(View(supplierAccountViewModel));
        }