public void Fill()
        {
            CategoryRepository        _categoryRepo = new CategoryRepository();         // Repozytorium kategorii firm.
            ServiceProviderRepository _providerRepo = new ServiceProviderRepository();  // Repozytorium uzytkowników.

            // Wypełnienie listy kategorii firm danymi w postaci: nazwa kategorii - ID kategorii
            Categories = _categoryRepo.GetAllCategories()
                         .Select(a => new { a.Name, a.Id })
                         .ToList()
                         .Select(a => new SelectListItem
            {
                Text     = a.Name,
                Value    = a.Id.ToString(),
                Selected = a.Id == SelectedCategoryId
            })
                         .ToList();

            // Wypełnienie listy użytkowników danymi w postaci: nazwa użytkownika - ID użytkownika
            Users = _providerRepo.GetServiceProviders()
                    .Select(a => new { a.Name, a.UserId })
                    .ToList()
                    .Select(a => new SelectListItem
            {
                Text     = a.Name,
                Value    = Convert.ToString(a.UserId),
                Selected = a.UserId == SelectedProviderId
            })
                    .ToList();
        }
Beispiel #2
0
        public JsonResult getdoctorbyname(string name, long typeId)
        {
            // long typid = 56; // retturn only doctor

            List <ServiceProvider> serviceProviders = null;
            List <ServiceProvidedWithReferrerFee> onlyserviceProviders = new List <ServiceProvidedWithReferrerFee>();

            using (ServiceProviderRepository repository = new ServiceProviderRepository())
            {
                serviceProviders = repository.GetServiceProviderPartialName(name, typeId).ToList();

                foreach (ServiceProvider item in serviceProviders)
                {
                    ServiceProvidedWithReferrerFee serviceProvider = new ServiceProvidedWithReferrerFee();
                    Contact contact = new Contact();
                    serviceProvider.Contact = contact;

                    serviceProvider.Contact.FirstName = item.Contact.FirstName;
                    serviceProvider.Contact.LastName  = item.Contact.LastName;
                    serviceProvider.Id             = item.Id;
                    serviceProvider.Speciality     = item.Speciality;
                    serviceProvider.DepartmentName = item.Department.Name;

                    onlyserviceProviders.Add(serviceProvider);
                }
            }

            return(Json(onlyserviceProviders, JsonRequestBehavior.AllowGet));
        }
 // Konstruktor kontrolera użytkownika.
 public CompanyUserController()
 {
     // Inicjalizacja repozytoriów
     _providerRepo = new ServiceProviderRepository();
     _companyRepo  = new CompanyRepository();
     _commentRepo  = new CommentRepository();
 }
Beispiel #4
0
        public JsonResult getDoctorByID(long serviceProviderID, long typeId, long itemid)
        {
            // long typid = 56; // retturn only doctor

            ServiceProvider serviceProviders = null;
            ServiceProvidedWithReferrerFee onlyserviceProviders = new ServiceProvidedWithReferrerFee();

            using (ServiceProviderRepository repository = new ServiceProviderRepository())
            {
                serviceProviders = repository.GetById(serviceProviderID);



                ServiceProvidedWithReferrerFee serviceProvider = new ServiceProvidedWithReferrerFee();
                Contact contact = new Contact();
                serviceProvider.Contact = contact;

                serviceProvider.Contact.FirstName = serviceProviders.Contact.FirstName;
                serviceProvider.Contact.LastName  = serviceProviders.Contact.LastName;
                serviceProvider.Id         = serviceProviders.Id;
                serviceProvider.Speciality = serviceProviders.Speciality;

                Referral referral = new Referral();

                using (ReferralRepository referrerrepository = new ReferralRepository())
                {
                    referral = referrerrepository.GetReferrer(serviceProvider.Id, itemid);
                    serviceProvider.ReferralFee = referral.ReferralFee;
                }

                onlyserviceProviders = serviceProvider;
            }

            return(Json(onlyserviceProviders, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
 // Konstruktor kontrolera firm.
 public CompanyController()
 {
     _companyRepo  = new CompanyRepository();
     _categoryRepo = new CategoryRepository();
     _providerRepo = new ServiceProviderRepository();
     _customerRepo = new CustomerRepository();
     _commentRepo  = new CommentRepository();
     _opinionRepo  = new OpinionRepository();
 }
 public void DeleteServiceProvider(string serviceProviderId)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     ServiceProvider serviceProvider = new ServiceProvider();
     serviceProvider = repo.GetAll().Where(x => x.ServiceProviderId == serviceProviderId).SingleOrDefault();
     repo.Delete(x => x.ServiceProviderId == serviceProvider.ServiceProviderId);
     //unitOfWork.Commit();
 }
Beispiel #7
0
        public void ReadMethod_ReturnsNullWhenItemNotFound()
        {
            //ASSEMBLE
            int testId = 100;

            //ACT
            var result = ServiceProviderRepository.Read(testId);

            //ASSERT
            Assert.Null(result);
        }
Beispiel #8
0
        public void ReadMethod_ShouldReadProviderFromProviderRepository()
        {
            //ASSEMBLE
            int testId = 1;

            //ACT
            var result = ServiceProviderRepository.Read(testId);

            //ASSERT
            Assert.NotNull(result);
        }
Beispiel #9
0
        public void Fill()
        {
            CategoryRepository        _categoryRepo        = new CategoryRepository();
            ServiceProviderRepository _serviceProviderRepo = new ServiceProviderRepository();

            //Categories = new SelectList(_categoryRepo.GetAllCategories(), "CategoryId", "Name", SelectedCategoryId);
            //ServiceProvider = new SelectList(_serviceProviderRepo.GetAllServiceProvider(), "ServiceProviderId", "Name", SelectedServiceProviderId);

            Categories      = new SelectList(_categoryRepo.GetAllCategories(), "CategoryId", "Name", SelectedCategoryId);
            ServiceProvider = new SelectList(_serviceProviderRepo.GetAllServiceProvider(), "ServiceProviderId", "Name", SelectedServiceProviderId);
        }
Beispiel #10
0
        // GET: ServiceProvider/Details/5
        public ActionResult Details(int id)
        {
            //Somehow my method ServiceProviderRepository.GetAppointmentsForProviderByDay is supposed
            //to get implemented - dunno how. It will not let me.
            //like absolutely no idea
            //what do i do? Ive tried so many things creating different views etc
            //and right now Its due and Im over it

            ServiceProviderRepository.GetAppointmentsForProviderByDay(id);
            return(View(ServiceProviderRepository.GetProvider(id)));
        }
Beispiel #11
0
 public ActionResult Delete(int id, ServiceProviderModel serviceProvider)
 {
     try
     {
         ServiceProviderRepository.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #12
0
 public ActionResult Create(ServiceProviderModel serviceProvider)
 {
     try
     {
         ServiceProviderRepository.Create(serviceProvider);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ServiceProviderModel GetServiceProviderById(string serviceProviderId)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     ServiceProviderModel serviceProviderModel = new ServiceProviderModel();
     ServiceProvider serviceProvider = new ServiceProvider();
     AutoMapper.Mapper.Map(serviceProviderModel, serviceProvider);
     serviceProvider = repo.GetAll().Where(x => x.ServiceProviderId == serviceProviderId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, serviceProviderModel);
     return serviceProviderModel;
 }
 public List<ServiceProviderModel> GetAllServiceProviders()
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     List<ServiceProviderModel> serviceProviderList = new List<ServiceProviderModel>();
     List<ServiceProvider> serviceProvider = new List<ServiceProvider>();
     AutoMapper.Mapper.Map(serviceProviderList, serviceProvider);
     serviceProvider = repo.GetAll().OrderByDescending(x=>x.ServiceProviderId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, serviceProviderList);
     return serviceProviderList;
 }
 public List<ServiceProviderModel> GetAllServiceProvidersAsIndividual()
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     List<ServiceProviderModel> serviceProviderList = new List<ServiceProviderModel>();
     List<ServiceProvider> serviceProvider = new List<ServiceProvider>();
     AutoMapper.Mapper.Map(serviceProviderList, serviceProvider);
     serviceProvider = repo.GetAll().Where(x=>x.ServiceProviderType== ServiceProviderType.Individual).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, serviceProviderList);
     return serviceProviderList;
 }
Beispiel #16
0
		public async Task<IActionResult> Providers(int id)
		{
			var repo = new ServiceProviderRepository();
			var services = await repo.GetAllAsync(it => it.ServiceId == id);
			var model = new ServiceProvidersViewModel
			{
				ServiceProviers = services,
				ServiceId = id,
			};
			repo.Dispose();

			return View(model);
		}
Beispiel #17
0
 public ActionResult Edit(int id, ServiceProvider provider)
 {
     try
     {
         // TODO: Add update logic here
         ServiceProviderRepository.Update(id, provider);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #18
0
 public ActionResult Create(ServiceProvider providers)
 {
     try
     {
         // TODO: Add insert logic here
         ServiceProviderRepository.Add(providers);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #19
0
 public ActionResult Delete(int id, IFormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         ServiceProviderRepository.DeleteProvider(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #20
0
        public ServiceController()
        {
            _serviceRepo         = new ServiceRepository();
            _customerRepo        = new CustomerRepository();
            _categoryRepo        = new CategoryRepository();
            _commentRepo         = new CommentRepository();
            _serviceProviderRepo = new ServiceProviderRepository();

            if (!int.TryParse(ConfigurationManager.AppSettings["DaysNumber"], out daysNumber))
            {
                daysNumber = 7;
            }
        }
 public bool CheckExistance(string serviceProviderId)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     var client = repo.GetAll().Where(x => x.ServiceProviderId == serviceProviderId).Count();
     //unitOfWork.Commit();
     if (client > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Beispiel #22
0
        public async Task <IActionResult> Providers(int id)
        {
            var repo     = new ServiceProviderRepository();
            var services = await repo.GetAllAsync(it => it.ServiceId == id);

            var model = new ServiceProvidersViewModel
            {
                ServiceProviers = services,
                ServiceId       = id,
            };

            repo.Dispose();

            return(View(model));
        }
Beispiel #23
0
        public IHttpActionResult GetLocations()
        {
            var           sp   = new ServiceProviderRepository(new AnyHireDbContext()).GetAll();
            List <string> locs = new List <string>();

            foreach (var item in sp)
            {
                foreach (var loc in item.Coverage.Split(','))
                {
                    if (!locs.Contains(loc))
                    {
                        locs.Add(loc);
                    }
                }
            }
            return(Ok(locs));
        }
        public void SetUp()
        {
            ConnectionProvider = new DataConnectionProvider(DataConnectionProvider.Connectionstring);

            UserTokenRepository = new UserTokenRecordRepository(ConnectionProvider);

            ServiceProviderRepository =new ServiceProviderRepository(ConnectionProvider);

            AuthProviderFactory = new AuthProviderFactory(new[]
                {
                    new FacebookAuthProviderInstance()
                });
            AuthConsumerService = new AuthConsumerService(UserTokenRepository,
                ServiceProviderRepository, AuthProviderFactory);

            new Registration().CreateTablesForTypes();
        }
Beispiel #25
0
        public async Task <IActionResult> EditProvider(int id)
        {
            var groupItems = await GetGroupItems();

            var repo     = new ServiceProviderRepository();
            var provider = await repo.GetByIdAsync(id);

            var model = new EditProviderViewModel
            {
                Provider   = provider,
                GroupItems = groupItems,
            };

            repo.Dispose();

            return(View(model));
        }
Beispiel #26
0
		private static async Task<ServiceResultDto[]> GetResultsAsync(ServiceIdentifierDto[] identifiers)
		{
			using (var repository = new ServiceProviderRepository())
			{
				var tasks = identifiers
					.Select(async item =>
					{
						try
						{
							var serviceMapping = await repository.GetAsync(it => it.Service.Name == item.Name
								&& it.Group == item.Group).ConfigureAwait(false);

							var addr = new ServiceInfoDto
							{
								Name = item.Name,
								Group = item.Group,
								Address = serviceMapping.Address,
								Data = serviceMapping.Data,
							};

							var result = new ServiceResultDto
							{
								Identifier = item,
								ServiceInfos = new[] { addr }
							};

							return result;
						}
						catch (Exception ex)
						{
							LogHelper.Error(ex);
						}
						return null;
					})
					.ToArray();

				await Task.WhenAll(tasks).ConfigureAwait(false);

				var results = tasks
						.Select(it => it.Result)
						.Where(it => it != null)
						.ToArray();
				return results;
			}
		}
Beispiel #27
0
        private static async Task <ServiceResultDto[]> GetResultsAsync(ServiceIdentifierDto[] identifiers)
        {
            using (var repository = new ServiceProviderRepository())
            {
                var tasks = identifiers
                            .Select(async item =>
                {
                    try
                    {
                        var serviceMapping = await repository.GetAsync(it => it.Service.Name == item.Name &&
                                                                       it.Group == item.Group).ConfigureAwait(false);

                        var addr = new ServiceInfoDto
                        {
                            Name    = item.Name,
                            Group   = item.Group,
                            Address = serviceMapping.Address,
                            Data    = serviceMapping.Data,
                        };

                        var result = new ServiceResultDto
                        {
                            Identifier   = item,
                            ServiceInfos = new[] { addr }
                        };

                        return(result);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(ex);
                    }
                    return(null);
                })
                            .ToArray();

                await Task.WhenAll(tasks).ConfigureAwait(false);

                var results = tasks
                              .Select(it => it.Result)
                              .Where(it => it != null)
                              .ToArray();
                return(results);
            }
        }
        public void CanServiceProviderRepositoryDeleteProvider()
        {
            //arrange
            var testProvider = new ServiceProvider()
            {
                Id   = 10,
                Name = "NoHands McGee"
            };

            //act
            ServiceProviderRepository.Add(testProvider);
            ServiceProviderRepository.DeleteProvider(testProvider.Id);

            //assert
            var p = ServiceProviderRepository.Providers.FirstOrDefault(x => x.Id == testProvider.Id);

            Assert.Null(p);
        }
Beispiel #29
0
        public void CanServiceProviderRepositoryDeleteProvider()
        {
            //arrange
            var mockSpaContext             = new Mock <SpaContext>(null);
            var mockReadOnlySpaContext     = new Mock <IReadOnlySpaContext>();
            ServiceProviderRepository repo = new ServiceProviderRepository(
                mockSpaContext.Object, mockReadOnlySpaContext.Object);
            var testProvider = new ServiceProvider()
            {
                Id   = 10,
                Name = "NoHands McGee"
            };

            //act
            repo.Add(testProvider);
            repo.DeleteProvider(testProvider.Id);

            //assert
            var p = repo.ServiceProviders.FirstOrDefault(x => x.Id == testProvider.Id);

            Assert.Null(p);
        }
Beispiel #30
0
        public async Task <IActionResult> EditProvider(EditProviderViewModel model, int serviceId)
        {
            var groupItems = await GetGroupItems();

            model.GroupItems = groupItems;

            if (model.Provider.Id == 0)
            {
                model.Provider.ServiceId = serviceId;
                using (var repo1 = new ServiceProviderRepository())
                {
                    await repo1.AddAsync(model.Provider);

                    return(View(model));
                }
            }

            var repo = new ServiceProviderRepository();
            await repo.UpdateAsync(model.Provider);

            return(View(model));
        }
Beispiel #31
0
 // GET: Customer/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(ServiceProviderRepository.Read(id)));
 }
 public List<ServiceProviderModel> GetServiceProviderListById(string[] serviceProviderIds)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     List<ServiceProviderModel> serviceProviderModel = new List<ServiceProviderModel>();
     List<ServiceProvider> serviceProvider = new List<ServiceProvider>();
     AutoMapper.Mapper.Map(serviceProviderModel, serviceProvider);
     serviceProvider = repo.GetAll().Where(x => serviceProviderIds.Contains(x.ServiceProviderId) && x.IsActive==true).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, serviceProviderModel);
     return serviceProviderModel;
 }
 // Konstruktor kontrolera Account
 public AccountController()
 {
     // Inicjalizacja repozytoriów
     _customerRepo        = new CustomerRepository();
     _serviceProviderRepo = new ServiceProviderRepository();
 }
Beispiel #34
0
 // GET: ServiceProvider/Delete/5
 public ActionResult Delete(int id)
 {
     return(View(ServiceProviderRepository.GetProvider(id)));
 }
 public ServiceProviderController()
 {
     _serviceProviderRepo = new ServiceProviderRepository();
     _commentRepo         = new CommentRepository();
     _serviceRepo         = new ServiceRepository();
 }
 public NewsletterController()
 {
     _servisProviderRepo = new ServiceProviderRepository();
     _customerRepo       = new CustomerRepository();
 }
 public ServiceProviderModel UpadteServiceProvider(ServiceProviderModel model)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     ServiceProvider serviceProvider = new ServiceProvider();
     serviceProvider = repo.GetAll().Where(x => x.ServiceProviderId == model.ServiceProviderId).SingleOrDefault();
     AutoMapper.Mapper.Map(model, serviceProvider);
     //serviceProvider.IsActive = model.IsActive;
     repo.Update(serviceProvider);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, model);
     return model;
 }
 public ServiceProviderModel SaveServiceProvider(ServiceProviderModel model)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     ServiceProvider serviceProvider = new ServiceProvider();
     AutoMapper.Mapper.Map(model, serviceProvider);
     repo.Insert(serviceProvider);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProvider, model);
     return model;
 }
 public List<ServiceProviderModel> Paging(PagingModel model)
 {
     //unitOfWork.StartTransaction();
     ServiceProviderRepository repo = new ServiceProviderRepository(unitOfWork);
     List<ServiceProviderModel> serviceProviderModelList = new List<ServiceProviderModel>();
     List<ServiceProvider> serviceProviderList = new List<ServiceProvider>();
     //ResponseMessage responseMessage = new ResponseMessage();
     //PagingInfo Info = new PagingInfo();
     string searchparam = model.SearchText == null ? "" : model.SearchText;
     serviceProviderList = repo.GetAll().Where(x => x.CompanyName.ToLower().Contains(searchparam.ToLower())).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(serviceProviderList, serviceProviderModelList);
     return serviceProviderModelList;
 }
Beispiel #40
0
		public async Task<IActionResult> EditProvider(int id)
		{
			var groupItems = await GetGroupItems();

			var repo = new ServiceProviderRepository();
			var provider = await repo.GetByIdAsync(id);
			var model = new EditProviderViewModel
			{
				Provider = provider,
				GroupItems = groupItems,
			};
			repo.Dispose();

			return View(model);
		}
Beispiel #41
0
		public async Task<IActionResult> EditProvider(EditProviderViewModel model, int serviceId)
		{
			var groupItems = await GetGroupItems();
			model.GroupItems = groupItems;

			if (model.Provider.Id == 0)
			{
				model.Provider.ServiceId = serviceId;
				using (var repo1 = new ServiceProviderRepository())
				{
					await repo1.AddAsync(model.Provider);
					return View(model);
				}
			}

			var repo = new ServiceProviderRepository();
			await repo.UpdateAsync(model.Provider);
			return View(model);
		}