Пример #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)
            {
                PopulateStreetTerritory(_context, InaccessibleTerritory.StreetTerritoryId);
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InaccessibleTerritoryExists(InaccessibleTerritory.TerritoryId))
                {
                    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)
            {
                PopulateSelectLists(_context, DoNotContactStreet.TerritoryId, DoNotContactStreet.PublisherId);
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoNotContactStreetExists(DoNotContactStreet.DoNotContactStreetId))
                {
                    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)
            {
                PopulateTerritory(_context);
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InaccessiblePropertyExists(InaccessibleProperty.InaccessiblePropertyId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("../InaccessibleTerritories/Details", new { id = InaccessibleProperty.TerritoryId }));
        }
Пример #4
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(Publisher).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PublisherExists(Publisher.PublisherId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            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()
        {
            if (!ModelState.IsValid)
            {
                PopulateStreetTerritory(_context);
                return(Page());
            }
            _context.InaccessibleTerritories.Add(InaccessibleTerritory);
            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()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.InaccessibleContacts.Add(InaccessibleContact);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #7
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.Publishers.Add(Publisher);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #8
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)
            {
                PopulateSelectLists(_context);
                return(Page());
            }

            _context.DoNotContactLetters.Add(DoNotContactLetter);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #9
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)
            {
                PopulateTerritory(_context);
                return(Page());
            }

            _context.InaccessibleProperties.Add(InaccessibleProperty);
            await _context.SaveChangesAsync();

            return(RedirectToPage("../InaccessibleTerritories/Details", new { id = InaccessibleProperty.TerritoryId }));
        }
Пример #10
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            InaccessibleProperty = await _context.InaccessibleProperties.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Пример #11
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DoNotContactStreet = await _context.DoNotContactStreets.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Пример #12
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Publisher = await _context.Publishers.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Пример #13
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var serializer = new JsonSerializer();

            using (var memoryStream = new MemoryStream())
            {
                await Upload.CopyToAsync(memoryStream);

                using (var streamReader = new StreamReader(memoryStream))
                    using (var jsonTextReader = new JsonTextReader(streamReader))
                    {
                        await memoryStream.FlushAsync();

                        memoryStream.Position = 0;

                        var uploadJson = (JArray)JToken.ReadFrom(jsonTextReader);

                        //validate the json

                        var list = new InaccessibleContactList()
                        {
                            InaccessiblePropertyId = id ?? 0,
                            CreateDate             = System.DateTime.UtcNow
                        };

                        foreach (JObject objContact in uploadJson)
                        {
                            PhoneTypeEnum phoneType;

                            switch ((string)objContact["PhoneType"])
                            {
                            case "C":
                                phoneType = PhoneTypeEnum.Mobile;
                                break;

                            case "M":
                                phoneType = PhoneTypeEnum.Mobile;
                                break;

                            case "L":
                                phoneType = PhoneTypeEnum.Landline;
                                break;

                            case "V":
                                phoneType = PhoneTypeEnum.Voip;
                                break;

                            default:
                                phoneType = PhoneTypeEnum.Landline;
                                break;
                            }

                            list.Contacts.Add(
                                new InaccessibleContact()
                            {
                                FirstName       = (string)objContact["FirstName"],
                                LastName        = (string)objContact["LastName"],
                                MiddleInitial   = (string)objContact["MiddleInitial"],
                                Age             = (int)objContact["Age"],
                                MailingAddress1 = (string)objContact["MailingAddress1"],
                                MailingAddress2 = (string)objContact["MailingAddress2"],
                                PostalCode      = (string)objContact["PostalCode"],
                                PhoneNumber     = (string)objContact["PhoneNumber"],
                                PhoneTypeId     = (int)phoneType
                            }
                                );
                        }

                        await _context.InaccessibleContactLists.AddAsync(list);

                        await _context.SaveChangesAsync();

                        var property = new InaccessibleProperty()
                        {
                            InaccessiblePropertyId = id ?? 0, CurrentContactListId = list.InaccessibleContactListId
                        };
                        _context.InaccessibleProperties.Attach(property);
                        _context.Entry(property).Property(X => X.CurrentContactListId).IsModified = true;
                        await _context.SaveChangesAsync();
                    }
            }

            InaccessibleProperty = await _context.InaccessibleProperties
                                   .Include(i => i.Territory)
                                   .ThenInclude(x => x.StreetTerritory)
                                   .AsNoTracking()
                                   .FirstOrDefaultAsync(m => m.InaccessiblePropertyId == id);

            if (InaccessibleProperty.CurrentContactListId != null)
            {
                InaccessibleContactList = await _context.InaccessibleContactLists
                                          .Include(x => x.Contacts)
                                          .AsNoTracking()
                                          .FirstOrDefaultAsync(x => x.InaccessibleContactListId == InaccessibleProperty.CurrentContactListId);
            }

            if (InaccessibleProperty == null)
            {
                return(NotFound());
            }
            return(Page());
        }