示例#1
0
        public async Task<IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return Page();
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicationUserExists(ApplicationUser.Id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return RedirectToPage("./Index");
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync()
        {
            MakeRequest = false;
            if (GoLive)
            {
                Advert.Status = 1;
            }
            else
            {
                Advert.Status = 0;
            }
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Advert.Status == 1)
            {
                if (InitialStatus != 1)
                {
                    MakeRequest = true;
                }
            }

            //Advert thing = _context.Adverts.Where(A => A.AdvertId == Advert.AdvertId);
            //_context.Remove(_context.Adverts.Where(A => A.AdvertId == Advert.AdvertId).GetEnumerator().Current);
            _context.Attach(Advert).State = EntityState.Modified;
            //_context.Attach(Advert).State = EntityState.Unchanged;

            if (MakeRequest)
            {
                Request request = new Request()
                {
                    AdvertId     = Advert.AdvertId,
                    Approval     = 1,
                    DateCreation = DateTime.Now
                };

                _context.Requests.Add(request);
            }


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdvertExists(Advert.AdvertId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
示例#3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (Approved)
            {
                Request.Approval = 2;
            }
            else
            {
                Request.Approval = 0;
            }


            Request.DateResponse = DateTime.Now;
            //_context.Attach(Request).State = EntityState.Unchanged;
            _context.Attach(Request).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RequestExists(Request.RequestId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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