예제 #1
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.Attach(Founder).State = EntityState.Modified;

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

            return(RedirectToPage("./Index"));
        }
예제 #2
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());
            }
            Client.ClientCreatedDate = DateTime.Now;
            Client.ClientUpdatedDate = Client.ClientCreatedDate;
            if (Client.ClientType != "ИП")
            {
                if (JsonFounders != null)
                {
                    Client.Founders = JsonSerializer.Deserialize <ICollection <Founder> >(JsonFounders);
                }
            }
            else
            {
                JsonFounders = null;
            }
            _context.Clients.Add(Client);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch
            {
                ErrorMessage = "Такой ИНН уже существует";
                return(Page());
            }

            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.Founders.Add(Founder);
            await _context.SaveChangesAsync();

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

            Founder = await _context.Founders.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
예제 #5
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(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Client.ClientType != "ИП")
            {
                if (JsonFounders != null)
                {
                    var missingRows = _context.Founders
                                      .Where(i => i.Client.ID == id);
                    _context.Founders.RemoveRange(missingRows);
                    _context.SaveChanges();

                    Client.Founders = JsonSerializer.Deserialize <ICollection <Founder> >(JsonFounders);
                }
            }
            else
            {
                JsonFounders = null;
            }
            _context.Attach(Client).State = EntityState.Modified;

            try
            {
                Client.ClientUpdatedDate = DateTime.Now;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientExists(Client.ID))
                {
                    return(NotFound());
                }
                else
                {
                    ErrorMessage = "Такой ИНН уже существует";
                    return(Page());
                }
            }

            return(RedirectToPage("./Index"));
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

            if (Client != null)
            {
                var missingRows = _context.Founders
                                  .Where(i => i.Client.ID == id);
                _context.Founders.RemoveRange(missingRows);
                _context.Clients.Remove(Client);
                await _context.SaveChangesAsync();
            }

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