예제 #1
0
        public static AuthnRequestType GetSamlAuthnRequest(HttpContext context, ServiceProviderModel serviceProvider)
        {
            var authnRequest = new AuthnRequestType()
            {
                ID                          = AuthnRequestID = Guid.NewGuid().ToString(),
                Version                     = "2.0",
                IssueInstant                = DateTime.UtcNow,
                ProtocolBinding             = Saml2Constants.ProtocolBindings.HTTP_Post,
                AssertionConsumerServiceURL = serviceProvider.AssertionConsumerServiceUrl //$"{ context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}",
            };

            authnRequest.Issuer = new NameIDType {
                Value = serviceProvider.Name
            };
            authnRequest.NameIDPolicy = new NameIDPolicyType {
                Format = Saml2Constants.NameIdentifierFormats.Unspecified, AllowCreate = true
            };
            authnRequest.RequestedAuthnContext = new RequestedAuthnContextType
            {
                Comparison       = AuthnContextComparisonType.exact,
                Items            = new string[] { "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" },
                ItemsElementName = new[] { ItemsChoiceType7.AuthnContextClassRef }
            };

            return(authnRequest);
        }
예제 #2
0
        public static List <ServiceProviderModel> SPList(string service, int Id)
        {
            ServicesContext             SerObj = new ServicesContext();
            List <ServiceProviderModel> SPList = new List <ServiceProviderModel>();
            //var SPResult = from a in SerObj.Users where a.Service == service select a;
            //Change
            //var ServiceProviders = SerObj.ServicesAssigned.Include("Service").Include("SP")
            //    .Join(SerObj.ServiceProviders,Assigned=>Assigned.ServiceProviderFK,SP=>SP.Id,(Assigned,SP)=>new {Assigned.Charge,SP.UserId,SP.Contact,Assigned.Service,Assigned.ServiceProviderFK })
            //    .Join(SerObj.Users, g => g.UserId, u => u.Id, (g, u) => new {g.Charge,g.Service,g.Contact,u.Username,g.ServiceProviderFK})
            //    .Where(g => g.Service.Service == service).Select(i => i);
            var ServiceProviders = from a in SerObj.Users
                                   join b in SerObj.ServicesAssigned on a.Id equals b.SP.UserId
                                   where b.Service.Service == service
                                   select new { a.Id,
                                                a.Username,
                                                b.Service.Service,
                                                b.Charge,
                                                b.ServiceProviderFK, };


            foreach (var i in ServiceProviders)
            {
                var ServiceObj = new ServiceProviderModel();

                ServiceObj.ServiceProviderId = i.ServiceProviderFK;

                ServiceObj.ServiceProviderName = i.Username;
                ServiceObj.Rating     = Data.Average(i.Id);
                ServiceObj.CustomerId = Id;
                ServiceObj.Price      = i.Charge;
                SPList.Add(ServiceObj);
            }
            return(SPList);
        }
        public async Task <ActionResult> Edit(ServiceProviderModel provider, OrganizationModel org)
        {
            try
            {
                provider.Organization = new OrganizationModel();

                if (provider.Activetab.ToLower() == "tab-2")
                {
                    provider.Organization = org;
                }

                provider.CreatedBy = CurrentUser.UserId;
                var response = await _provider.AddUpdateDeleteProvider(provider);

                _provider.Save();
                // TODO: Add insert logic here
                TempData["response"] = "Edited Successfully";

                // TODO: Add update logic here

                return(RedirectToAction("index"));
            }
            catch
            {
                return(View(provider));
            }
        }
예제 #4
0
        public static void ValidateSubject(SubjectType subject, ServiceProviderModel serviceProvider)
        {
            if (subject == null)
            {
                throw new ArgumentNullException(nameof(subject));
            }

            bool validContentFound = false;

            if (subject.Items == null || subject.Items.Length == 0)
            {
                throw new Exception("Subject must contain either an identifier or a subject confirmation");
            }

            foreach (object o in subject.Items)
            {
                if (o is NameIDType)
                {
                    validContentFound = true;
                    ValidateNameID((NameIDType)o);
                }
                if (o is SubjectConfirmationType)
                {
                    validContentFound = true;
                    ValidateSubjectConfirmation((SubjectConfirmationType)o, serviceProvider);
                }
            }

            if (!validContentFound)
            {
                throw new Exception("Subject must have NameID and SubjectConfirmation");
            }
        }
예제 #5
0
        public void ServiceProviderDetails_ReturnsAViewResult()
        {
            //ARRANGE
            var testServiceProvider = new ServiceProviderModel {
                Id = 1
            };
            var testAppts = new List <AppointmentModel>
            {
                new AppointmentModel
                {
                    Id = 1,
                    AppointmentTime = new DateTime(2018, 12, 01, 11, 00, 00),
                    ProviderId      = 1
                }
            };
            var mockIRepo = new Mock <IRepository>();

            mockIRepo.Setup(x => x.GetAppointmentsForProvider(testServiceProvider.Id)).Returns(testAppts);
            var testController = new ServiceProviderController(mockIRepo.Object);

            //ACT
            var result = testController.Details(1, testServiceProvider);

            //ASSERT
            Assert.IsType <ViewResult>(result);
            Assert.Equal(1, testServiceProvider.Id);
        }
예제 #6
0
        public ActionResult ServiceProviderCalendarDetails(string spid)
        {
            int sp_id = Convert.ToInt32(EncryptionUtility.Decrypt(spid.ToString(), true));
            ServiceProviderModel model = new ServiceProviderModel();

            return(PartialView("_SPCalendarModal", model));
        }
예제 #7
0
        private async void SetSessionValuesAsync(ServiceProviderModel model)
        {
            var claims = new List <Claim>
            {
                new Claim("UserId", model.id.ToString(), ClaimValueTypes.Integer),
                new Claim("FirstName", model.firstName.ToString().Trim(), ClaimValueTypes.String),
                new Claim("LastName", model.lastName.ToString().Trim(), ClaimValueTypes.String),
                new Claim("FullName", string.Format("{0} {1}", model.firstName.Trim(), model.lastName.Trim()), ClaimValueTypes.String),
                new Claim("Email", model.emailAddress.ToString().Trim(), ClaimValueTypes.String),
                new Claim("CompanyName", model.companyName.ToString().Trim(), ClaimValueTypes.String),
                new Claim("CompanyPostcode", model.postcode.ToString().Trim(), ClaimValueTypes.String),
                new Claim("Trade", model.service.ToString().Trim(), ClaimValueTypes.String),
                new Claim("ContactNumber", model.contactNumber.ToString().Trim(), ClaimValueTypes.String),
            };

            var userIdentity  = new ClaimsIdentity(claims, "UserCookieScheme");
            var userPrincipal = new ClaimsPrincipal(userIdentity);

            HttpContext.Session.SetString("LogUserString", string.Format("[{0}] {1} {2} <{3}>",
                                                                         model.id, model.firstName, model.lastName, model.emailAddress));

            await HttpContext.SignInAsync("UserCookieScheme", userPrincipal,
                                          new AuthenticationProperties
            {
                ExpiresUtc   = DateTime.UtcNow.AddMinutes(60),
                IsPersistent = false,
            }
                                          );
        }
예제 #8
0
        public IActionResult Signup()
        {
            ServiceProviderModel model = new ServiceProviderModel();

            List <ServiceModel> services = TheRepository.GetServices().ToList();

            var servicesList = services.Select(x => new SelectListItem
            {
                Text  = x.Service.ToString(),
                Value = x.id.ToString()
            }).ToList();

            List <MembershipModel> memberships = TheRepository.GetMemberships().ToList();

            var membershipList = memberships.Select(x => new SelectListItem
            {
                Text = String.Format("{0} - £{1} pm (+ {2}% commission on sales)", x.name.ToString(),
                                     x.basicSubscriptionFee.ToString(), x.commission),
                Value = x.id.ToString()
            }).ToList();

            ViewData["Services"]    = servicesList;
            ViewData["Memberships"] = membershipList;

            model.memberships = membershipList;
            model.services    = servicesList;

            return(View(model));
        }
예제 #9
0
        public ServiceProvider Parse(ServiceProviderModel serviceprovider)
        {
            if (serviceprovider == null)
            {
                return(null);
            }

            return(new ServiceProvider()
            {
                AddressLine1 = serviceprovider.addressLine1,
                AddressLine2 = serviceprovider.addressLine2,
                City = serviceprovider.city,
                CompanyName = serviceprovider.companyName,
                CompanyNumber = serviceprovider.companyNumber,
                CompanySize = serviceprovider.companyNumber,
                IsVatRegistered = serviceprovider.isVATRegistered,
                Vatnumber = serviceprovider.VATNumber,
                ContactNumber = serviceprovider.contactNumber,
                Country = serviceprovider.country,
                DeactivationReason = serviceprovider.deactivationReason,
                Description = serviceprovider.description,
                EmailAddress = serviceprovider.emailAddress,
                FirstName = serviceprovider.firstName,
                IsActive = Convert.ToBoolean(serviceprovider.isActive),
                LastName = serviceprovider.lastName,
                Postcode = serviceprovider.postcode,
                TradeId = Convert.ToInt32(serviceprovider.serviceId),
                Website = serviceprovider.website,
                MembershipId = Convert.ToInt32(serviceprovider.membershipId),
                EmailConfirmed = Convert.ToBoolean(serviceprovider.emailConfirmed),
                VerifyCode = serviceprovider.VerifyCode
            });
        }
예제 #10
0
        public static void ValidateConditions(ConditionsType conditions, ServiceProviderModel serviceProvider)
        {
            if (conditions.NotBefore == default(DateTime) || conditions.NotOnOrAfter == default(DateTime))
            {
                throw new Exception($"{nameof(conditions.NotBefore)} or {nameof(conditions.NotOnOrAfter)} is invalid");
            }

            if (conditions.NotBefore >= conditions.NotOnOrAfter)
            {
                throw new Exception($"{nameof(conditions.NotBefore)} should be lesser than {nameof(conditions.NotOnOrAfter)}");
            }

            foreach (ConditionAbstractType condition in conditions.Items)
            {
                if (conditions.Items.Count() <= 0)
                {
                    throw new Exception($"{nameof(conditions.Items)} array cannnot be empty");
                }

                if (condition is AudienceRestrictionType audienceRestrictionType)
                {
                    if (!audienceRestrictionType.Audience.Any(a => a == serviceProvider.Name))
                    {
                        throw new Exception($"{audienceRestrictionType.Audience} does not mention {serviceProvider.Name}");
                    }
                }
            }
        }
예제 #11
0
        public IActionResult LoginProcess(LoginModel login, string returnUrl = "")
        {
            if (IsValid(login) != null)
            {
                ServiceProviderModel model = new ServiceProviderModel();
                model = TheRepository.GetServiceProviderByEmail(login.userName);

                ServiceModel services = new ServiceModel();
                services      = TheRepository.GetServiceById(model.serviceId);
                model.service = services.Service;

                //if user is inactive or locked out, do not proceed any further
                if (Convert.ToBoolean(model.isActive) == false)
                {
                    ModelState.AddModelError("", "Your account is currently inactive. Please " +
                                             "contact [email protected] to activate yor account");
                    return(View(model));
                }


                //If valid, then set the session values
                SetSessionValuesAsync(model);

                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }

                return(RedirectToAction("Index", "ServiceProvider"));
            }

            return(View("Login"));
        }
예제 #12
0
        public IActionResult Profile()
        {
            int id = this.GetCurrentUserId();

            if (id > 0)
            {
                ServiceProviderModel model = TheRepository.GetServiceProvider(Convert.ToInt32(id));

                if (model != null)
                {
                    model.slots = TheRepository.GetAvailabilitySlots(Convert.ToInt32(id));
                }

                var ratings = TheRepository.GetRatings(model.id);

                if ((ratings != null) && (ratings.Count > 0))
                {
                    model.rating = ratings.Average(a => a.ratings);
                }
                model.ratings = ratings;

                model.newslot      = new SlotsModel();
                model.selectedPage = "Profile";
                return(View(model));
            }

            return(View());
        }
예제 #13
0
        public IActionResult AddSchedule(ServiceProviderModel model)
        {
            SlotsModel slotsmodel = new SlotsModel();

            slotsmodel           = model.newslot;
            slotsmodel.dayOfWeek = Request.Form["dayofweek"].ToString();
            int minimumHours = 0;

            if (Request.Form["newslot.minimumHours"].ToString() != String.Empty)
            {
                if (Request.Form["newslot.minimumHours"].ToString() == "1 hr")
                {
                    minimumHours = 1;
                }
                else if (Request.Form["newslot.minimumHours"].ToString() == "2 hrs")
                {
                    minimumHours = 2;
                }
                else if (Request.Form["newslot.minimumHours"].ToString() == "0.5 day")
                {
                    minimumHours = 4;
                }
                else if (Request.Form["newslot.minimumHours"].ToString() == "1 day")
                {
                    minimumHours = 8;
                }
            }
            slotsmodel.minimumHours      = minimumHours;
            slotsmodel.serviceproviderId = Convert.ToInt32(Request.Form["id"].ToString());
            TheRepository.CreateSlot(slotsmodel);

            return(RedirectToAction("schedules"));
        }
예제 #14
0
        public IActionResult Invoices()
        {
            int id = this.GetCurrentUserId();

            if (id > 0)
            {
                ServiceProviderModel model = TheRepository.GetServiceProvider(Convert.ToInt32(id));

                if (model != null)
                {
                    model.invoices = TheRepository.GetInvoicesByServiceProvider(Convert.ToInt32(id));
                }
                var ratings = TheRepository.GetRatings(model.id);

                if ((ratings != null) && (ratings.Count > 0))
                {
                    model.rating = ratings.Average(a => a.ratings);
                }
                model.ratings      = ratings;
                model.selectedPage = "Invoices";
                return(View(model));
            }

            return(View());
        }
예제 #15
0
        public IActionResult Index()
        {
            int id = this.GetCurrentUserId();

            if (id > 0)
            {
                ServiceProviderModel model = TheRepository.GetServiceProvider(id);

                if (model != null)
                {
                    model.bookings = TheRepository.GetAllBookings(id);
                }

                List <BookingModel> bookingModels = new List <BookingModel>();

                bookingModels = TheRepository.GetAllBookings(model.id);

                var ratings = TheRepository.GetRatings(model.id);

                if ((ratings != null) && (ratings.Count > 0))
                {
                    model.rating = ratings.Average(a => a.ratings);
                }
                model.ratings             = ratings;
                model.totalCustomers      = bookingModels.Count();
                model.totalCustomersToday = bookingModels.Where(a => a.bookingDate == DateTime.Now).Count();
                model.totalNewBookings    = bookingModels.Where(a => a.bookingDate > DateTime.Now).Count();

                return(View(model));
            }

            return(View());
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,name,service,phone_number,url")] ServiceProviderModel serviceProviderModel)
        {
            if (id != serviceProviderModel.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(serviceProviderModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServiceProviderModelExists(serviceProviderModel.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(serviceProviderModel));
        }
        //Update Method
        public static void Update(int id, ServiceProviderModel serviceProvider)
        {
            var index = _providers.FindIndex(x => x.Id == id);

            _providers.RemoveAt(index);
            serviceProvider.Id = id;
            _providers.Insert(index, serviceProvider);
        }
예제 #18
0
        public IActionResult addquestion(ServiceProviderModel model)
        {
            ServiceProviderAdditionalQuestionsModel questionsmodel = new ServiceProviderAdditionalQuestionsModel();

            questionsmodel = model.additionalQuestion;
            questionsmodel.serviceProviderId = model.id;
            TheRepository.CreateAdditionalQuestions(questionsmodel);
            return(RedirectToAction("additionalquestions"));
        }
예제 #19
0
        public IActionResult ConfirmEmail(string id)
        {
            var decryptedid            = EncryptionUtility.Decrypt(id.ToString());
            ServiceProviderModel model = new ServiceProviderModel();

            model = TheRepository.GetServiceProvider(Convert.ToInt32(decryptedid));
            model.emailConfirmed = true;
            TheRepository.UpdateServiceProvider(model, model);
            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("id,name,service,phone_number,url")] ServiceProviderModel serviceProviderModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(serviceProviderModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(serviceProviderModel));
        }
예제 #21
0
        public static void PlaceOrder(ServiceProviderModel NewOrder)
        {
            ServicesContext ContextObj = new ServicesContext();
            Order           orderObj   = new Order()
            {
                Date = DateTime.Now, FinalPrice = NewOrder.Price, ScheduleDate = NewOrder.ScheduledDate, FromFK = NewOrder.CustomerId, Status = "Active", ToFK = NewOrder.ServiceProviderId
            };

            ContextObj.Orders.Add(orderObj);
            ContextObj.SaveChanges();
        }
 public ActionResult SaveServiceProviders(ServiceProviderModel model)
 {
     if (ModelState.IsValid)
     {
         var dbModel = Mapper.Map <ServiceProviderModel, ServiceProvider>(model);
         dbModel.CreatedOn = DateTime.Now;
         dbModel.IsDeleted = true;
         InsuranceContext.ServiceProviders.Insert(dbModel);
         return(RedirectToAction("ProvidersList"));
     }
     return(View());
 }
예제 #23
0
 public ActionResult Edit(int id, ServiceProviderModel serviceProvider)
 {
     try
     {
         ServiceProviderRepository.Update(id, serviceProvider);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult EditProviders(ServiceProviderModel model)
 {
     if (ModelState.IsValid)
     {
         var data = Mapper.Map <ServiceProviderModel, ServiceProvider>(model);
         data.CreatedOn = DateTime.Now;
         data.IsDeleted = true;
         InsuranceContext.ServiceProviders.Update(data);
         return(RedirectToAction("ProvidersList"));
     }
     return(View());
 }
 public ActionResult Delete(int id, ServiceProviderModel serviceProvider)
 {
     try
     {
         _repository.DeleteProvider(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(ServiceProviderModel serviceProvider)
 {
     try
     {
         _repository.AddProvider(serviceProvider);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #27
0
        public async Task <ServiceProviderModel> GetProviderById(Guid?serviceProviderId)
        {
            var          ProviderModel = new ServiceProviderModel();
            SqlParameter client        = new SqlParameter("@ProviderId", ToDBNull(serviceProviderId));

            using (var connection = _context.Database.Connection)
            {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = "USPGetProviderById";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(client);
                using (var reader = await command.ExecuteReaderAsync())
                {
                    ProviderModel =
                        ((IObjectContextAdapter)_context)
                        .ObjectContext
                        .Translate <ServiceProviderModel>(reader)
                        .SingleOrDefault();
                    if (ProviderModel == null)
                    {
                        ProviderModel = new ServiceProviderModel();
                    }
                    ProviderModel.CurrentProviderName = ProviderModel.ProviderName;

                    reader.NextResult();

                    ProviderModel.Organization =
                        ((IObjectContextAdapter)_context)
                        .ObjectContext
                        .Translate <OrganizationModel>(reader)
                        .SingleOrDefault();
                    if (ProviderModel.Organization != null)
                    {
                        ProviderModel.Organization.OrgGSTFileUrl = "/UploadedImages/Providers/Gsts/" + ProviderModel.Organization.OrgGSTFileName;
                        ProviderModel.Organization.OrgPanFileUrl = "/UploadedImages/Providers/PANCards/" + ProviderModel.Organization.OrgPanFileName;
                    }
                    reader.NextResult();
                    ProviderModel.ContactPersons = ReadPersons(reader);
                    reader.NextResult();
                    ProviderModel.BankDetails = ReadBanks(reader);
                    reader.NextResult();
                    ProviderModel.Services =
                        ((IObjectContextAdapter)_context)
                        .ObjectContext
                        .Translate <ServiceOfferedModel>(reader)
                        .ToList();
                }
            }

            return(ProviderModel);
        }
예제 #28
0
 public static void ValidateAssertion(AssertionType assertion, ServiceProviderModel serviceProvider)
 {
     try
     {
         SamlValidationHelper.ValidateAssertionAttributes(assertion);
         SamlValidationHelper.ValidateSubject(assertion.Subject, serviceProvider);
         SamlValidationHelper.ValidateConditions(assertion.Conditions, serviceProvider);
         SamlValidationHelper.ValidateStatements(assertion.Items, serviceProvider);
     }
     catch (Exception ex)
     {
         throw new Exception("Authentication failed", ex);
     }
 }
예제 #29
0
파일: Repository.cs 프로젝트: anandfs/INYT
        internal ServiceProviderModel CreateServiceProvider(ServiceProviderModel model)
        {
            var sp = _modelFactory.Parse(model);

            _db.ServiceProvider.Add(sp);

            try
            {
                _db.SaveChanges();
                return(_modelFactory.Create(sp));
            }
            catch (DbUpdateException ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #30
0
 public string Put([FromBody] ServiceProviderModel value)
 {
     try
     {
         if (value.Validate().Length == 0)
         {
             _repo.Update(value);
             return(JsonConvert.SerializeObject(new ResultModel($"Provider {value.ShopName} Updated!", false)));
         }
         return(JsonConvert.SerializeObject(new ResultModel(value.Validate().Aggregate((a, b) => $"{a} | {b}"), true)));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new ResultModel(ex.Message, true)));
     }
 }