public T GetRepo <T>(CustomerDbContext context)
        {
            dynamic result = null;

            if (typeof(T) == typeof(IAddressRepository))
            {
                result = new AddressRepository(context);
            }
            if (typeof(T) == typeof(IContactRepository))
            {
                result = new ContactRepository(context);
            }
            if (typeof(T) == typeof(ICustomerRepository))
            {
                result = new CustomerRepository(context);
            }
            if (typeof(T) == typeof(IAddressTypeRepository))
            {
                result = new AddressTypeRepository(context);
            }
            if (typeof(T) == typeof(IContactTypeRepository))
            {
                result = new ContactTypeRepository(context);
            }
            if (typeof(T) == typeof(ICustomerAddressRepository))
            {
                result = new CustomerAddressRepository(context);
            }
            if (typeof(T) == typeof(ICustomerContactsRepository))
            {
                result = new CustomerContactsRepository(context);
            }
            return((T)result);
        }
        // GET: /Create
        public ActionResult Create(int id, string csu, string tt)
        {
            ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType();

            clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(id);

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

            ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType();

            clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt);

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

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

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

            TravelerTypeContactVM travelerTypeContactVM = new TravelerTypeContactVM();

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);
            travelerTypeContactVM.ClientSubUnit = clientSubUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(id);
            travelerTypeContactVM.ClientDetail = clientDetail;

            TravelerType travelerType = new TravelerType();

            travelerType = travelerTypeRepository.GetTravelerType(tt);
            travelerTypeContactVM.TravelerType = travelerType;

            Contact contact = new Contact();

            travelerTypeContactVM.Contact = contact;

            ContactTypeRepository contactTypeRepository = new ContactTypeRepository();

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

            return(View(travelerTypeContactVM));
        }
        public static ContactTypeRepository GetContactTypeRepository()
        {
            var dependencyResolverFaker = DependencyResolverFaker.GetDependencyResolver();

            var contractTypeRepository = new ContactTypeRepository(dependencyResolverFaker);

            return(contractTypeRepository);
        }
Example #4
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(id);

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

            ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit();

            clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(id);

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

            string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid;


            ClientTopUnit clientTopUnit = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid);

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

            if (rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid))
            {
                ViewData["Access"] = "WriteAccess";
            }

            ClientTopUnitContactVM clientTopUnitContactVM = new ClientTopUnitContactVM();

            clientTopUnitContactVM.ClientTopUnit = clientTopUnit;
            clientTopUnitContactVM.ClientDetail  = clientDetail;

            Contact contact = new Contact();

            clientTopUnitContactVM.Contact = contact;

            ContactTypeRepository contactTypeRepository = new ContactTypeRepository();

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

            return(View(clientTopUnitContactVM));
        }
        // 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));
        }
        public IHttpActionResult UpdateContactTypeStatus([FromBody] ContactType contacttype)
        {
            var contacttypeRepo = new ContactTypeRepository();
            var result          = contacttypeRepo.UpdateContactTypeStatus(contacttype);

            if (result <= 0)
            {
                return(Ok("Error occurred while updating the contact type status"));
            }
            return(Ok("Contact Type Status updated"));
        }
        public IHttpActionResult GetContactType([FromBody] ContactType contactType)
        {
            var contacttypeRepo = new ContactTypeRepository();
            var getcontacttype  = contacttypeRepo.GetContactType(contactType);

            if (getcontacttype == null)
            {
                return(NotFound());
            }
            return(Ok(getcontacttype));
        }
        // GET: api/ContactType
        public IHttpActionResult GetAllContactTypes()
        {
            var contacttypeRepo = new ContactTypeRepository();
            var contacttypeList = contacttypeRepo.GetAllContactTypes();

            if (contacttypeList == null || contacttypeList.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(contacttypeList));
        }
        static void Main(string[] args)
        {
            UnitOfWork uof = new UnitOfWork(ContextType.AdventureWorks2012Context);

            uof.GetRepo<ContactTypeRepository>().Insert(new ContactType { ContactTypeID = 133, ModifiedDate = DateTime.Now, Name = "Type1" });
            uof.GetRepo<ContactTypeRepository>().Insert(new ContactType { ContactTypeID = 134, ModifiedDate = DateTime.Now, Name = "Type2" });
            uof.GetRepo<AddressTypeRepository>().Insert(new AddressType { AddressTypeID = 450, ModifiedDate = DateTime.Now, Name = "Type121", rowguid = new Guid() });
            uof.Commit();

            ContactTypeRepository contactRepo = new ContactTypeRepository();
            contactRepo.Insert(new ContactType { ContactTypeID = 107, ModifiedDate = DateTime.Now, Name = "Type3" });
            contactRepo.Commit();
        }
Example #10
0
 public UnitOfWork(EllegiaContext context)
 {
     _context              = context;
     Colors                = CreateCommonHandbookRepository <Color>();
     PlasticBagTypes       = CreateCommonHandbookRepository <PlasticBagType>();
     FilmTypes             = new FilmTypeRepository(context);
     FilmTypeOptions       = new CommonHandbookRepository <FilmTypeOption>(context);
     Shifts                = new CommonHandbookRepository <Shift>(context);
     Customers             = new CustomerRepository(context);
     ContactTypes          = new ContactTypeRepository(context);
     ProductTypes          = new ProductTypeRepository(context);
     Orders                = new OrderRepository(context);
     OrderRoutes           = new Repository <OrderRoute>(context);
     Users                 = new UserRepository(context);
     Warehouses            = new WarehouseRepository(context);
     WarehouseInOutHistory = new WarehouseInOutHistoryRepository(context);
 }
Example #11
0
        static void Main(string[] args)
        {
            UnitOfWork uof = new UnitOfWork(ContextType.AdventureWorks2012Context);

            uof.GetRepo <ContactTypeRepository>().Insert(new ContactType {
                ContactTypeID = 133, ModifiedDate = DateTime.Now, Name = "Type1"
            });
            uof.GetRepo <ContactTypeRepository>().Insert(new ContactType {
                ContactTypeID = 134, ModifiedDate = DateTime.Now, Name = "Type2"
            });
            uof.GetRepo <AddressTypeRepository>().Insert(new AddressType {
                AddressTypeID = 450, ModifiedDate = DateTime.Now, Name = "Type121", rowguid = new Guid()
            });
            uof.Commit();

            ContactTypeRepository contactRepo = new ContactTypeRepository();

            contactRepo.Insert(new ContactType {
                ContactTypeID = 107, ModifiedDate = DateTime.Now, Name = "Type3"
            });
            contactRepo.Commit();
        }
Example #12
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            ClientDetailContact clientDetailContact = new ClientDetailContact();

            clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id);

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

            int clientDetailId = clientDetailContact.ClientDetailId;
            ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit();

            clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId);

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

            string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid;


            ClientTopUnit clientTopUnit = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid);

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

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

            ClientTopUnitContactVM clientTopUnitContactVM = new ClientTopUnitContactVM();

            clientTopUnitContactVM.ClientTopUnit = clientTopUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);
            clientTopUnitContactVM.ClientDetail = clientDetail;

            Contact contact = new Contact();

            contact = contactRepository.GetContact(clientDetailContact.ContactId);
            clientTopUnitContactVM.Contact = contact;

            ContactTypeRepository contactTypeRepository = new ContactTypeRepository();

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

            return(View(clientTopUnitContactVM));
        }
        // GET: /Edit
        public ActionResult Edit(string csu, int id)
        {
            ClientDetailContact clientDetailContact = new ClientDetailContact();

            clientDetailContact = clientDetailContactRepository.GetContactClientDetail(id);

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

            int clientDetailId = clientDetailContact.ClientDetailId;
            ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType();

            clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(clientDetailId);

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

            string tt = clientDetailTravelerType.TravelerTypeGuid;
            ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType();

            clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt);

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

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

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

            TravelerTypeContactVM travelerTypeContactVM = new TravelerTypeContactVM();

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);
            travelerTypeContactVM.ClientSubUnit = clientSubUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);
            travelerTypeContactVM.ClientDetail = clientDetail;

            TravelerType travelerType = new TravelerType();

            travelerType = travelerTypeRepository.GetTravelerType(tt);
            travelerTypeContactVM.TravelerType = travelerType;

            Contact contact = new Contact();

            contact = contactRepository.GetContact(clientDetailContact.ContactId);
            travelerTypeContactVM.Contact = contact;

            ContactTypeRepository contactTypeRepository = new ContactTypeRepository();

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

            return(View(travelerTypeContactVM));
        }