public async Task <IActionResult> GetUser([FromRoute] Guid userId,
                                                  CancellationToken cancellationToken)
        {
            Models.UserDetails userDetailsModel = await this.Manager.GetUser(userId, cancellationToken);

            return(this.Ok(this.ModelFactory.ConvertFrom(userDetailsModel)));
        }
Esempio n. 2
0
        public void ModelFactory_ConvertFrom_ListUserDetails_ModelsConverted()
        {
            IModelFactory modelFactory = new ModelFactory();

            UserDetails userDetailsModel = new UserDetails
            {
                PhoneNumber = SecurityServiceManagerTestData.PhoneNumber,
                Username    = SecurityServiceManagerTestData.UserName,
                Roles       = SecurityServiceManagerTestData.Roles,
                UserId      = Guid.Parse(SecurityServiceManagerTestData.User1Id),
                Email       = SecurityServiceManagerTestData.EmailAddress,
                Claims      = SecurityServiceManagerTestData.Claims
            };
            List <UserDetails> userDetailsModelList = new List <UserDetails>();

            userDetailsModelList.Add(userDetailsModel);

            List <DataTransferObjects.Responses.UserDetails> userDetailsDtoList = modelFactory.ConvertFrom(userDetailsModelList);

            userDetailsDtoList.ShouldNotBeNull();
            userDetailsDtoList.ShouldNotBeEmpty();
            userDetailsDtoList.Count.ShouldBe(userDetailsModelList.Count);
            userDetailsDtoList.First().UserName.ShouldBe(SecurityServiceManagerTestData.UserName);
            userDetailsDtoList.First().EmailAddress.ShouldBe(SecurityServiceManagerTestData.EmailAddress);
            userDetailsDtoList.First().PhoneNumber.ShouldBe(SecurityServiceManagerTestData.PhoneNumber);
            userDetailsDtoList.First().UserId.ShouldBe(Guid.Parse(SecurityServiceManagerTestData.User1Id));
            userDetailsDtoList.First().Claims.ShouldBe(SecurityServiceManagerTestData.Claims);
            userDetailsDtoList.First().Roles.ShouldBe(SecurityServiceManagerTestData.Roles);
        }
        public void RegisterUser(Models.UserDetails userdetails)
        {
            string query = "insert into UserDetails (FirstName,LastName,Email,Password,MobileNumber,UserType)" +
                           "Values(@FirstName,@LastName,@Email,@Password,@MobileNumber,@UserType)";

            connection.Execute(query, new { userdetails.FirstName, userdetails.LastName, userdetails.Email, userdetails.Password, userdetails.MobileNumber, userdetails.UserType });
        }
Esempio n. 4
0
        public ActionResult Register(Models.UserDetails userdetails)
        {
            MovieInformation movieinfo = new MovieInformation();

            movieinfo.RegisterUser(userdetails);
            return(View("Registration"));
        }
Esempio n. 5
0
        public ActionResult CreateUser(Models.NewUser param)
        {
            param.company  = "Spectrum Management Authority, Jamaica";
            param.clientId = 11698;

            if (Session["key"] != null)
            {
                param.access_key = Session["key"].ToString();
                var client = new HttpClient();
                client.BaseAddress = new Uri("http://server-erp2.sma.gov.jm:1786/api/user/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var content = new StringContent(JsonConvert.SerializeObject(param), Encoding.UTF8, "application/json");
                HttpResponseMessage response = client.PostAsync("RegisterCompanyUserV2", content).Result;
                if (response.IsSuccessStatusCode)
                {
                    string             result      = response.Content.ReadAsStringAsync().Result;
                    Models.UserDetails userDetails = JsonConvert.DeserializeObject <Models.UserDetails>(result);
                    return(Json(new { userDetails, }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    string result = response.Content.ReadAsStringAsync().Result;
                    return(Json(new { result, }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized, "invalid session"));
            }
        }
Esempio n. 6
0
        public void ModelFactory_ConvertFrom_UserDetails_ModelIsNull_NullReturned()
        {
            IModelFactory modelFactory = new ModelFactory();

            UserDetails userDetailsModel = null;

            DataTransferObjects.Responses.UserDetails userDetailsDto = modelFactory.ConvertFrom(userDetailsModel);

            userDetailsDto.ShouldBeNull();
        }
Esempio n. 7
0
        public IActionResult GetUserDetails(Guid id)
        {
            var user        = base.GetById(id);
            var userDetails = new Models.UserDetails()
            {
                Id        = user.Id,
                Email     = user.Email,
                UserName  = user.UserName,
                Disabled  = user.IsActive.Value,
                UserType  = user.UserType,
                FirstName = user.FirstName,
                LastName  = user.LastName
            };

            var applicationPermissions = new List <Models.ApplicationPermission>();

            foreach (var userAppRole in user.UserAppRoleMapping)
            {
                // Use this Join roleDetails -- It has all required details
                var roleDetails = GetRelatedPrivilegesForRoleAndApp(userAppRole.RoleId,
                                                                    userAppRole.ApplicationId);

                if (roleDetails.Count > 0)
                {
                    var applicationPermission = new Models.ApplicationPermission();
                    applicationPermission.Id     = userAppRole.ApplicationId;
                    applicationPermission.Name   = roleDetails[0].ApplicationName;
                    applicationPermission.RoleId = userAppRole.Role.Id;
                    applicationPermission.Role   = roleDetails[0].RoleName;

                    Dictionary <int, Models.FeaturePermission> featurePermissions = new Dictionary <int, Models.FeaturePermission>();
                    foreach (var roleDetail in roleDetails)
                    {
                        Models.FeaturePermission featurePermission = new Models.FeaturePermission();
                        featurePermission.FeatureTypeId   = roleDetail.FeatureTypeId;
                        featurePermission.TypeName        = roleDetail.FeatureTypeName;
                        featurePermission.Label           = roleDetail.FeatureLabel;
                        featurePermission.ParentFeatureId = roleDetail.ParentFeatureId;
                        featurePermission.Order           = roleDetail.Order;
                        featurePermission.Privileges      = roleDetail.Privileges;

                        // Todo: May be no need to add the Dictionary -- The below array should be OK
                        applicationPermission.FeaturePermissions.Add(featurePermission.FeatureTypeId, featurePermission);

                        // Added if we need the fearures as an array
                        applicationPermission.FeaturesList.Add(featurePermission);
                    }

                    applicationPermissions.Add(applicationPermission);
                }
            }
            userDetails.ApplicationPermissions = applicationPermissions;
            return(Ok(userDetails));
        }
Esempio n. 8
0
        //[Route("Member/UserEdit")]
        public ActionResult UserDataEdit([Bind(Include = "Id,Account,Email,Phone")] Models.UserDetails userdetails)
        {
            if (ModelState.IsValid)
            {
                AspNetUserManage edit = new AspNetUserManage();
                edit.EditUserDetails(userdetails);
                return(RedirectToAction("UserDataDetails"));
            }

            return(View(userdetails));
        }
Esempio n. 9
0
        public async Task <Models.UserDetails> LoadUser(string Email)
        {
            Models.UserDetails user = new Models.UserDetails();
            var dt = await Globals.SchoolDatabase.UserSelect(Email);

            if (dt.Rows.Count > 0)
            {
                var r = dt.Rows[0];
                user.UserId = Convert.ToInt32(r["UserId"]);
                user.Pwd    = r["Pwd"].ToString();
                user.Salt   = r["Salt"].ToString();
                user.Email  = Security.Decrypt(r["Email"].ToString());
            }
            return(user);
        }
        public Task HandleAsync(AddUserDetails command)
        {
            var userDetails = new Models.UserDetails
            {
                CreationDate = DateTime.Now,
                EmailAddress = command.EmailAddress,
                Name         = command.Name,
                Surname      = command.Surname,
                Id           = 3
            };

            _context.UserDetails.Add(userDetails);
            _context.SaveChanges();
            return(Task.CompletedTask);
        }
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public UserDetails ConvertFrom(Models.UserDetails model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new UserDetails
            {
                UserName = model.Username,
                PhoneNumber = model.PhoneNumber,
                Roles = model.Roles,
                Claims = model.Claims,
                UserId = model.UserId,
                EmailAddress = model.Email
            });
        }
        public ActionResult saveUserDetails(Models.UserDetails model)
        {
            UserDetail entity = new UserDetail();

            entity.FirstName = model.FirstName;
            entity.LastName  = model.LastName;
            entity.BirthDate = model.BirthDate;
            string emailID = (string)Session["User"];
            bool   log     = repo.userRegistration(entity, emailID);

            if (log)
            {
                return(View("Success"));
            }
            else
            {
                return(View("Error"));
            }
        }
Esempio n. 13
0
        public void ModelFactory_ConvertFrom_UserDetails_ModelConverted()
        {
            IModelFactory modelFactory = new ModelFactory();

            UserDetails userDetailsModel = new UserDetails
            {
                PhoneNumber = SecurityServiceManagerTestData.PhoneNumber,
                Username    = SecurityServiceManagerTestData.UserName,
                Roles       = SecurityServiceManagerTestData.Roles,
                UserId      = Guid.Parse(SecurityServiceManagerTestData.User1Id),
                Email       = SecurityServiceManagerTestData.EmailAddress,
                Claims      = SecurityServiceManagerTestData.Claims
            };

            DataTransferObjects.Responses.UserDetails userDetailsDto = modelFactory.ConvertFrom(userDetailsModel);

            userDetailsDto.UserName.ShouldBe(SecurityServiceManagerTestData.UserName);
            userDetailsDto.EmailAddress.ShouldBe(SecurityServiceManagerTestData.EmailAddress);
            userDetailsDto.PhoneNumber.ShouldBe(SecurityServiceManagerTestData.PhoneNumber);
            userDetailsDto.UserId.ShouldBe(Guid.Parse(SecurityServiceManagerTestData.User1Id));
            userDetailsDto.Claims.ShouldBe(SecurityServiceManagerTestData.Claims);
            userDetailsDto.Roles.ShouldBe(SecurityServiceManagerTestData.Roles);
        }
Esempio n. 14
0
        public ActionResult Login(Models.Login model_login)
        {
            MovieInformation movieinfo = new MovieInformation();

            Models.UserDetails user  = new Models.UserDetails();
            MovieRegistration  movie = new MovieRegistration();
            string             val   = movieinfo.checkUser(model_login);

            if (ModelState.IsValid)
            {
                if (val != "")
                {
                    if (val == "Provider")
                    {
                        Session["Email"] = model_login.Email;


                        var state = movieinfo.StateNameList().ToList();
                        var city  = movieinfo.CityNameList().ToList();
                        var area  = movieinfo.AreaNameList().ToList();

                        foreach (var item in state)
                        {
                            movie.StateNameList.Add(item);
                        }
                        foreach (var item in city)
                        {
                            movie.CityNameList.Add(item);
                        }
                        foreach (var item in area)
                        {
                            movie.AreaNameList.Add(item);
                        }
                        return(View("../Registration/TheaterExistence", movie));
                    }
                    else if (val == "User")
                    {
                        Session["Email"] = model_login.Email;
                        MovieBooking   moviebook = new MovieBooking();
                        TheaterDetails cinema    = new TheaterDetails();
                        var            StateList = movieinfo.StateNameList().ToList();
                        foreach (var item in StateList)
                        {
                            moviebook.StateNameList.Add(item);
                        }

                        return(View("MovieBooking", moviebook));
                    }
                    else
                    {
                        Session["Email"] = model_login.Email;
                        return(View("../Registration/StateRegistration", movie));
                    }
                }
                else
                {
                    ViewBag.Message = "Invalid Email and Password";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }