示例#1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("PCAccountID,ProfitCentreID,AccountID,Active,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate,RowVersion")] ProfitCentreAccount profitCentreAccount)
        {
            if (id != profitCentreAccount.PCAccountID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(profitCentreAccount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfitCentreAccountExists(profitCentreAccount.PCAccountID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountID"]      = new SelectList(_context.ChartOfAccounts, "AccountID", "AccountID", profitCentreAccount.AccountID);
            ViewData["ProfitCentreID"] = new SelectList(_context.ProfitCentres, "ProfitCentreID", "ProfitCentreID", profitCentreAccount.ProfitCentreID);
            return(View(profitCentreAccount));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("PCAccountID,ProfitCentreID,AccountID,Active,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate,RowVersion")] ProfitCentreAccount profitCentreAccount)
        {
            if (ModelState.IsValid)
            {
                profitCentreAccount.PCAccountID = Guid.NewGuid();
                _context.Add(profitCentreAccount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountID"]      = new SelectList(_context.ChartOfAccounts, "AccountID", "AccountID", profitCentreAccount.AccountID);
            ViewData["ProfitCentreID"] = new SelectList(_context.ProfitCentres, "ProfitCentreID", "ProfitCentreID", profitCentreAccount.ProfitCentreID);
            return(View(profitCentreAccount));
        }