Exemplo n.º 1
0
        public async Task <IActionResult> CreateTimBanksPost([Bind("Id,Customer,Incident,Started,Ended,Hours,Price,Total,Outlay,PersonId,Notes,WLNumber,TBPStatusId")] TimBanksPost timBanksPost)
        {
            if (ModelState.IsValid)
            {
                var nBSContext = _context.TimBanksPost
                                 .Include(t => t.TBPStatus)
                                 .Include(t => t.Employee);
                timBanksPost.Total = (timBanksPost.Hours * timBanksPost.Price) + timBanksPost.Outlay;

                _context.Add(timBanksPost);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(IndexSearchTimBanksPosts)));
            }

            ViewData["PersonId"]    = new SelectList(_context.Person, "Id", "FullName", timBanksPost.PersonId);
            ViewData["TBPStatusId"] = new SelectList(_context.TBPStatus, "Id", "TBPStatusName");
            return(View(timBanksPost));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditTimBanksPost(int id, [Bind("Id, Customer, Incident, Started, Ended, Hours, Price, Total, Outlay, PersonId, Notes, WLNumber, TBPStatusId")] TimBanksPost timBanksPost)
        {
            if (id != timBanksPost.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var nBSContext = _context.TimBanksPost
                                     .Include(t => t.TBPStatus)
                                     .Include(t => t.Employee);
                    timBanksPost.Total = (timBanksPost.Hours * timBanksPost.Price) + timBanksPost.Outlay;

                    _context.Update(timBanksPost);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TimBanksPostExists(timBanksPost.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(IndexSearchTimBanksPosts)));
            }
            ViewData["PersonId"]    = new SelectList(_context.Person, "Id", "FullName", timBanksPost.PersonId);
            ViewData["TBPStatusId"] = new SelectList(_context.TBPStatus, "Id", "TBPStatusName", timBanksPost.TBPStatusId);
            return(View(timBanksPost));
        }