예제 #1
0
        // GET: /Create
        public ActionResult Create()
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ViewData["CountryRegions"] = new SelectListItem();

            AddressLocationVM addressLocationVM = new AddressLocationVM();

            Location location = new Location();

            addressLocationVM.Location = location;

            Address address = new Address();

            addressLocationVM.Address = address;

            //StateProvince SelectList
            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();

            addressLocationVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(address.CountryCode).ToList(), "StateProvinceCode", "Name");

            return(View(addressLocationVM));
        }
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            Contact contact = new Contact();

            contact = clientSubUnitContactRepository.GetContact(id);

            //Check Exists
            if (contact == null)
            {
                ViewData["ActionMethod"] = "List";
                return(View("RecordDoesNotExistError"));
            }

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(contact.ClientSubUnitGuid);

            //Check Exists
            if (clientSubUnit == null)
            {
                ViewData["ActionMethod"] = "List";
                return(View("RecordDoesNotExistError"));
            }

            clientSubUnitRepository.EditGroupForDisplay(clientSubUnit);

            //Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

            if (rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnit.ClientSubUnitGuid))
            {
                ViewData["Access"] = "WriteAccess";
            }

            ContactVM contactVM = new ContactVM();

            contactVM.ClientSubUnit = clientSubUnit;
            clientSubUnitContactRepository.EditForDisplay(contact);
            contactVM.Contact = contact;

            ContactTypeRepository contactTypeRepository = new ContactTypeRepository();

            contactVM.ContactTypes = new SelectList(contactTypeRepository.GetAllContactTypes().ToList(), "ContactTypeId", "ContactTypeName", contact.ContactTypeId);

            CountryRepository countryRepository = new CountryRepository();

            contactVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName", contact.CountryCode);

            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();

            contactVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(contact.CountryCode).ToList(), "StateProvinceCode", "Name", contact.StateProvinceName);

            return(View(contactVM));
        }
예제 #3
0
        public ActionResult LocationDetailsScreen(int locationId = 0)
        {
            if (!hierarchyRepository.AdminHasDomainWriteAccess("Location"))
            {
                return(PartialView("Error", "You do not have access to this item"));
            }

            Location location = new Location();
            Address  address  = new Address();

            CountryRepository countryRepository = new CountryRepository();

            if (locationId > 0)
            {
                location = locationRepository.GetLocation(locationId);

                //Check Exists
                if (location == null)
                {
                    return(PartialView("Error", "Location Does Not Exist"));
                }

                //get Address
                address = locationRepository.GetLocationAddress(locationId);
                AddressRepository addressRepository = new AddressRepository();
                addressRepository.EditForDisplay(address);

                //add linked information
                locationRepository.EditForDisplay(location);
            }

            LocationWizardVM locationWizardViewModel = new LocationWizardVM();

            locationWizardViewModel.Location        = location;
            locationWizardViewModel.Address         = address;
            locationWizardViewModel.SystemUserCount = locationWizardRepository.GetLocationSystemUsers(locationId).Count;

            MappingQualityRepository mappingQualityRepository = new MappingQualityRepository();

            if (locationWizardViewModel.Address != null)
            {
                locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", locationWizardViewModel.Address.MappingQualityCode);
            }
            else
            {
                locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode");
            }

            //StateProvince SelectList
            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();

            locationWizardViewModel.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(location.CountryCode).ToList(), "StateProvinceCode", "Name", address.StateProvinceCode);

            return(PartialView("LocationDetailsScreen", locationWizardViewModel));
        }
예제 #4
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Check Exists
            Location location = new Location();

            location = locationRepository.GetLocation(id);
            if (location == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToLocation(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            AddressLocationVM addressLocationVM = new AddressLocationVM();

            locationRepository.EditForDisplay(location);
            addressLocationVM.Location = location;

            Address address = locationRepository.GetLocationAddress(id);

            if (address != null)
            {
                AddressRepository addressRepository = new AddressRepository();
                addressRepository.EditForDisplay(address);
                addressLocationVM.Address = address;
            }

            CountryRepository countryRepository = new CountryRepository();
            SelectList        countryRegionList = new SelectList(countryRepository.GetCountryRegions(location.CountryRegion.Country.CountryCode).ToList(), "CountryRegionId", "CountryRegionName");

            ViewData["CountryRegions"] = countryRegionList;

            //StateProvince SelectList
            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();

            addressLocationVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(location.CountryCode).ToList(), "StateProvinceCode", "Name", address.StateProvinceCode);

            return(View(addressLocationVM));
        }
예제 #5
0
        public ActionResult Delete(int id)
        {
            PseudoCityOrOfficeAddress pseudoCityOrOfficeAddress = new PseudoCityOrOfficeAddress();

            pseudoCityOrOfficeAddress = pseudoCityOrOfficeAddressRepository.GetPseudoCityOrOfficeAddress(id);

            //Check Exists
            if (pseudoCityOrOfficeAddress == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PseudoCityOrOfficeAddressVM pseudoCityOrOfficeAddressVM = new PseudoCityOrOfficeAddressVM();

            pseudoCityOrOfficeAddressVM.AllowDelete = true;

            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();
            StateProvince           stateProvince           = stateProvinceRepository.GetStateProvinceByCountry(pseudoCityOrOfficeAddress.CountryCode, pseudoCityOrOfficeAddress.StateProvinceCode);

            pseudoCityOrOfficeAddress.StateProvinceName = "";
            if (stateProvince != null)
            {
                pseudoCityOrOfficeAddress.StateProvinceName = stateProvince.Name;
            }

            //Attached Items
            List <PseudoCityOrOfficeAddressReference> pseudoCityOrOfficeAddressReferences = pseudoCityOrOfficeAddressRepository.GetPseudoCityOrOfficeAddressReferences(pseudoCityOrOfficeAddress.PseudoCityOrOfficeAddressId);

            if (pseudoCityOrOfficeAddressReferences.Count > 0)
            {
                pseudoCityOrOfficeAddressVM.AllowDelete = false;
                pseudoCityOrOfficeAddressVM.PseudoCityOrOfficeAddressReferences = pseudoCityOrOfficeAddressReferences;
            }

            pseudoCityOrOfficeAddressVM.PseudoCityOrOfficeAddress = pseudoCityOrOfficeAddress;

            return(View(pseudoCityOrOfficeAddressVM));
        }
예제 #6
0
 public SchemaRepositoryContainer()
 {
     #region Entity Repositories
     City                     = new CityRepository();
     Cities_Archive           = new Cities_ArchiveRepository();
     Country                  = new CountryRepository();
     Countries_Archive        = new Countries_ArchiveRepository();
     DeliveryMethod           = new DeliveryMethodRepository();
     DeliveryMethods_Archive  = new DeliveryMethods_ArchiveRepository();
     PaymentMethod            = new PaymentMethodRepository();
     PaymentMethods_Archive   = new PaymentMethods_ArchiveRepository();
     Person                   = new PersonRepository();
     People_Archive           = new People_ArchiveRepository();
     StateProvince            = new StateProvinceRepository();
     StateProvinces_Archive   = new StateProvinces_ArchiveRepository();
     SystemParameter          = new SystemParameterRepository();
     TransactionType          = new TransactionTypeRepository();
     TransactionTypes_Archive = new TransactionTypes_ArchiveRepository();
     #endregion
     // If not implemented this method is removed during compilation
     LoadCustomRepositories();
 }
예제 #7
0
 public AWUnitOfWork(AWContext context)
 {
     _context                = context;
     Address                 = new AddressRepository(context);
     BusinessEntity          = new BusinessEntityRepository(context);
     BusinessEntityAddress   = new BusinessEntityAddressRepository(context);
     PersonPhone             = new PersonPhoneRepository(context);
     StateProvince           = new StateProvinceRepository(context);
     Customer                = new CustomerRepository(context);
     SalesPerson             = new SalesPersonRepository(context);
     SalesOrderHeader        = new SalesOrderHeaderRepository(context);
     SalesOrderDetail        = new SalesOrderDetailRepository(context);
     ShoppingCartItem        = new ShoppingCartItemRepository(context);
     SalesTerritory          = new SalesTerritoryRepository(context);
     Product                 = new ProductRepository(context);
     ProductCategory         = new ProductCategoryRepository(context);
     ProductDescription      = new ProductDescriptionRepository(context);
     ProductInventory        = new ProductInventoryRepository(context);
     ProductListPriceHistory = new ProductListPriceHistoryRepository(context);
     ProductPhoto            = new ProductPhotoRepository(context);
     ProductProductPhoto     = new ProductProductPhotoRepository(context);
     Person = new PersonRepository(context);
 }
예제 #8
0
        public ActionResult ValidateLocation(LocationWizardVM locationWizardViewModel)
        {
            int locationId = 0;

            if (locationWizardViewModel.Location != null)
            {
                locationId = locationWizardViewModel.Location.LocationId;
            }

            //Validate Team data against Table
            if (!ModelState.IsValid)
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }

                //Need to repopulate List
                MappingQualityRepository mappingQualityRepository = new MappingQualityRepository();
                locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", locationWizardViewModel.Address.MappingQualityCode);;
                locationWizardViewModel.SystemUserCount     = locationWizardRepository.GetLocationSystemUsers(locationId).Count;

                //StateProvince SelectList
                StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();
                locationWizardViewModel.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(locationWizardViewModel.Location.CountryCode).ToList(), "StateProvinceCode", "Name", locationWizardViewModel.Address.StateProvinceCode);

                //Validation Error - retrun to Details Screen
                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "LocationDetailsScreen", locationWizardViewModel),
                    message = "ValidationError (" + n + ")",
                    success = false
                }));
            }

            //Location
            Location location = new Location();

            location = locationWizardViewModel.Location;
            LocationSystemUsersVM locationUsersScreen = new LocationSystemUsersVM();

            locationUsersScreen.Location = locationWizardViewModel.Location;

            // Systemusers
            List <spDDAWizard_SelectLocationSystemUsers_v1Result> systemUsers = new List <spDDAWizard_SelectLocationSystemUsers_v1Result>();

            systemUsers = locationWizardRepository.GetLocationSystemUsers(location.LocationId);
            locationUsersScreen.SystemUsers = systemUsers;

            //Show Location's systemUsers
            return(Json(new WizardJSONResponse
            {
                html = ControllerExtension.RenderPartialViewToString(this, "LocationUsersScreen", locationUsersScreen),
                message = "Success",
                success = true
            }));
        }