public async Task <IActionResult> Delete(int?id)
        {
            if (id != null)
            {
                TableAddress address = await _context.PersTableAddresson.FirstOrDefaultAsync(p => p.AddressId == id);

                Tablelocality tablelocality = await _context.Tablelocality.FirstOrDefaultAsync(p => p.localityId == address.localityId);

                TableDistrict tableDistrict = await _context.TableDistrict.FirstOrDefaultAsync(p => p.DistrictId == tablelocality.DistrictId);

                if (address != null)
                {
                    _context.PersTableAddresson.Remove(address);
                    await _context.SaveChangesAsync();

                    _context.Tablelocality.Remove(tablelocality);
                    await _context.SaveChangesAsync();

                    _context.TableDistrict.Remove(tableDistrict);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("OrganizationInformation"));
                }
            }
            return(NotFound());
        }
Beispiel #2
0
 public ColumnAddress(TableAddress address, string sColumnName)
 {
     m_sServerName   = address.GetServerName();
     m_sDatabaseName = address.GetDatabaseName();
     m_sTableName    = address.GetTableName();
     m_sColumnName   = sColumnName == null ? string.Empty : sColumnName.ToUpper();
 }
        public async Task <IActionResult> AddAdreess(InformationAboutTheAccountViewModel model)
        {
            int TableOrganizations = _context.TableOrganizations.Include(i => i.users).FirstOrDefault
                                         (i => User.Identity.Name == i.users.UserName).TableOrganizationsId;

            TableDistrict district = new TableDistrict
            {
                NameDistrict = model.District,
                AreaId       = model.areaId
            };

            _context.TableDistrict.Add(district);
            await _context.SaveChangesAsync();

            Tablelocality tablelocality = new Tablelocality
            {
                Typelocality = model.TypesOfLocalities.ToString(),
                DistrictId   = district.DistrictId,
                Namelocality = model.Namelocality
            };

            _context.Tablelocality.Add(tablelocality);
            await _context.SaveChangesAsync();

            TableAddress address = new TableAddress
            {
                Adress               = model.Adress,
                PostalCode           = model.PostalCode,
                TableOrganizationsId = TableOrganizations,
                localityId           = tablelocality.localityId,
            };

            _context.PersTableAddresson.Add(address);
            await _context.SaveChangesAsync();

            return(RedirectToAction("OrganizationInformation"));
        }
Beispiel #4
0
 public DatabaseAddress(TableAddress address)
 {
     m_sServerName   = address.GetServerName();
     m_sDatabaseName = address.GetDatabaseName();
 }