コード例 #1
0
ファイル: Edit.cshtml.cs プロジェクト: pfeif/request-tracker
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Technician).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TechnicianExists(Technician.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: pfeif/request-tracker
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(ServiceRequest).State = EntityState.Modified;

            // Detects concurrency exceptions when two clients (not IT clients) are trying to edit
            //  or delete data at the same time.
            // TODO: Implement store wins handling.
            //  https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/concurrency?view=aspnetcore-3.1&tabs=visual-studio
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceRequestExists(ServiceRequest.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Client = await _context.Client.FindAsync(id);

            if (Client != null)
            {
                _context.Client.Remove(Client);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Technician = await _context.Technician.FindAsync(id);

            if (Technician != null)
            {
                _context.Technician.Remove(Technician);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #6
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            // Catch model errors on the client's side.
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // Manually set the service request's open data and status.
            ServiceRequest.OpenDate = DateTime.Now;
            ServiceRequest.Status   = Status.Created;

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

            return(RedirectToPage("./Index"));
        }