Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("RHID,Cost,Work_description,Ticket_opened,Ticket_closed,Work_started,Work_ended,UnitUID,ContractorCID")] Repair_History repair_History)
        {
            if (id != repair_History.RHID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(repair_History);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Repair_HistoryExists(repair_History.RHID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractorCID"] = new SelectList(_context.Contractor, "CID", "CID", repair_History.ContractorCID);
            ViewData["UnitUID"]       = new SelectList(_context.Unit, "UID", "UID", repair_History.UnitUID);
            return(View(repair_History));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("RHID,Cost,Work_description,Ticket_opened,Ticket_closed,Work_started,Work_ended,UnitUID,ContractorCID")] Repair_History repair_History)
        {
            if (ModelState.IsValid)
            {
                _context.Add(repair_History);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractorCID"] = new SelectList(_context.Contractor, "CID", "CID", repair_History.ContractorCID);
            ViewData["UnitUID"]       = new SelectList(_context.Unit, "UID", "UID", repair_History.UnitUID);
            return(View(repair_History));
        }
        public async Task <IActionResult> Create([Bind("RHID,Cost,Work_description,Ticket_opened,Date_due,Ticket_closed,Work_started,Work_ended,UnitUID,ContractorCID")] Repair_History repair_History)
        {
            var units = from u in _context.Unit where u.UID == repair_History.UnitUID select u;

            ViewData["UnitUID"] = new SelectList(units, "UID", "Unit_Number");
            if (ModelState.IsValid)
            {
                _context.Add(repair_History);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractorCID"] = new SelectList(_context.Contractor, "CID", "Company_name", repair_History.ContractorCID);
            return(View(repair_History));
        }
        public async Task <IActionResult> Edit(int id, [Bind("RHID,Cost,Work_description,Ticket_opened,Date_due,Ticket_closed,Work_started,Work_ended,UnitUID,ContractorCID")] Repair_History repair_History)
        {
            if (id != repair_History.RHID)
            {
                return(NotFound());
            }

            var units       = from u in _context.Unit where u.UID == repair_History.UnitUID select u;
            var contractors = from c in _context.Contractor where c.CID == repair_History.ContractorCID select c;

            ViewData["ContractorCID"] = new SelectList(contractors, "CID", "Company_name");
            ViewData["UnitUID"]       = new SelectList(units, "UID", "Unit_Number");

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(repair_History);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Repair_HistoryExists(repair_History.RHID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(repair_History));
        }