public void Create(AspNetUserModel model, out string id)
        {
            try
            {
                _unitOfWork.BeginTransaction();

                id = "";

                var passwordHash = new PasswordHasher();
                var password     = passwordHash.HashPassword(model.Password);

                var entity = Mapper.Map <AspNetUserModel, AspNetUser>(model);
                entity.PasswordHash  = password;
                entity.SecurityStamp = Guid.NewGuid().ToString();
                entity.Id            = Guid.NewGuid().ToString();
                _repository.Insert(entity);

                /*var repository = _repository.GetRepository<IdentityUserRole>();
                 * var reposRole = _repository.GetRepository<AspNetRole>();
                 * repository.Insert(new IdentityUserRole()
                 * {
                 *  UserId = entity.Id,
                 *  RoleId = reposRole.Find(c=> c.Name == model.RoleName).Id
                 * });*/

                id = entity.Id;

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public string GetLoggedInFullName()
        {
            string          userId = HttpContext.Current.User.Identity.GetUserId();
            AspNetUserModel user   = UserService.GetUser(userId);

            return(string.Format("{0} {1}", user.FirstName, user.LastName));
        }
        public async Task EditUserRoleByUser(AspNetUserModel model)
        {
            var aspNetUserRoles = await _context.AspNetUserRoles.Where(x => x.UserId.ToLower().Trim() == model.Id.Trim().ToLower()).ToListAsync();

            if (aspNetUserRoles == null)
            {
                throw new NullReferenceException(String.Concat(_localizer["EditDataError"], _localizer["RoleNotFound"]));
            }

            var rolesToRemove = aspNetUserRoles.Where(x => !model.Roles.Select(u => u.Id).Contains(x.RoleId));
            var rolesToAdd    = model.Roles.Where(x => !aspNetUserRoles.Select(u => u.RoleId).Contains(x.Id));

            foreach (var role in rolesToRemove)
            {
                _context.Entry <AspNetUserRoles>(role).State = EntityState.Deleted;
            }

            foreach (var role in rolesToAdd)
            {
                var aspNetUserRole = new AspNetUserRoles
                {
                    RoleId = role.Id,
                    UserId = model.Id
                };
                await _context.AspNetUserRoles.AddAsync(aspNetUserRole);
            }

            await _context.SaveChangesAsync();
        }
        public AspNetUserModel GetAspNetUserModelWithIdDB(string Id)
        {
            AspNetUserModel aspNetUserModel = (from c in db.AspNetUsers
                                               where c.Id == Id
                                               select new AspNetUserModel
            {
                Error = "",
                Id = c.Id,
                Email = c.Email,
                EmailConfirmed = c.EmailConfirmed,
                PasswordHash = c.PasswordHash,
                SecurityStamp = c.SecurityStamp,
                PhoneNumber = c.PhoneNumber,
                PhoneNumberConfirmed = c.PhoneNumberConfirmed,
                TwoFactorEnabled = c.TwoFactorEnabled,
                LockoutEndDateUtc = c.LockoutEndDateUtc,
                LockoutEnabled = c.LockoutEnabled,
                AccessFailedCount = c.AccessFailedCount,
                UserName = c.UserName,
                LoginEmail = c.Email,
            }).FirstOrDefault <AspNetUserModel>();

            if (aspNetUserModel == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.AspNetUser, ServiceRes.Id, Id)));
            }

            return(aspNetUserModel);
        }
    private IEnumerator RegistrarAspNetUser()
    {
        AspNetUserModel aspUser = new AspNetUserModel();

        aspUser.Email           = inputFieldEmail.text;
        aspUser.Password        = inputFieldContra.text;
        aspUser.ConfirmPassword = inputFieldConfirmarContra.text;

        using (UnityWebRequest httpClient = new UnityWebRequest(player.HttpServerAddress + "/api/Account/Register", "POST"))
        {
            string bodyJson = JsonUtility.ToJson(aspUser);

            byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJson);

            httpClient.uploadHandler = new UploadHandlerRaw(bodyRaw);

            httpClient.SetRequestHeader("Content-type", "application/json");

            yield return(httpClient.SendWebRequest());

            if (httpClient.isNetworkError || httpClient.isHttpError)
            {
                throw new System.Exception("RegistrarAspNetUser > Error: " + httpClient.responseCode + ", Info: " + httpClient.error);
            }
        }
    }
Beispiel #6
0
    private IEnumerator RegisterAspNetUser()
    {
        AspNetUserModel aspPlayer = new AspNetUserModel();

        aspPlayer.Email           = emailInputField.text;
        aspPlayer.Password        = passwordInputField.text;
        aspPlayer.ConfirmPassword = confirmPasswordInputField.text;

        using (UnityWebRequest httpClient = new UnityWebRequest(httpServer + "/api/Account/Register", "POST"))
        {
            string bodyJson = JsonUtility.ToJson(aspPlayer);
            byte[] bodyRaw  = Encoding.UTF8.GetBytes(bodyJson);
            httpClient.uploadHandler = new UploadHandlerRaw(bodyRaw);
            httpClient.SetRequestHeader("Content-type", "application/json");

            yield return(httpClient.SendWebRequest());

            if (httpClient.isNetworkError || httpClient.isHttpError)
            {
                throw new Exception("RegisterNewPlayer > RegisterAspNetUser: "******"RegisterNewPlayer > RegisterAspNetUser: " + httpClient.responseCode);
            }
        }
    }
Beispiel #7
0
        public static AspNetUserModel GetUserModel()
        {
            AspNetUserModel aspNetUserModel = new AspNetUserModel();

            switch (MySession.Current.IsUserAdmin)
            {
            case true:
                aspNetUserModel.AspNetUserList = new Database.AspNetUsersEntities().AspNetUsers.ToList();
                break;

            case false:
                aspNetUserModel.AspNetUserList = new Database.AspNetUsersEntities().AspNetUsers
                                                 .ToList()
                                                 .Where(x => x.UserParentId == new Guid(MySession.Current.UserGuid))
                                                 .ToList();
                break;
            }

            var result = new Database.AspNetUsersEntities().AspNetUsers.ToList();

            //result.First().AspNetRoles.First().Name;

            //aspNetUserModel.UserRoleList = GetUserRoleList();

            return(aspNetUserModel);
        }
        public async Task <IActionResult> EditUserRoles([FromBody] AspNetUserModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (model == null)
                    {
                        throw new NullReferenceException(_localizer["InvalidModel"]);
                    }

                    await _roleService.EditUserRoleByUser(model);

                    return(Ok());
                }
                catch (Exception x)
                {
                    Log.Error($"ERROR Roles/CreateRole");
                    return(StatusCode(500, x.Message));
                }
            }
            else
            {
                return(BadRequest(_localizer["FillRequiredFields"]));
            }
        }
Beispiel #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            if (nddScore.Value <= 0)
            {
                lblError.Text = @"Score is required";
                return;
            }
            if ((nddScore.Value % 1) != 0)
            {
                lblError.Text = @"Score is whole number";
                return;
            }

            try
            {
                MatricNumber = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
                var studentDetails = $"{MatricNumber.FirstName} {MatricNumber.LastName}({MatricNumber.MatricNumber})";
                var level          = LevelService.GetItem(LevelId);

                if (level.SectionModels != null && level.SectionModels.Count > 0)
                {
                    var message      = $@"Result Details {Environment.NewLine}Matric Number: {studentDetails}{Environment.NewLine}Course: {(string)ddlCourse.SelectedValue}{Environment.NewLine}Result: {nddScore.Value}";
                    var dialogResult = MessageBox.Show(message, @"Result Details", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (dialogResult == DialogResult.OK)
                    {
                        var cId = CourseService.GetCourseByName((string)ddlCourse.SelectedValue).Id;
                        var courseWithResult = ResultService.CanSaveResult(MatricNumber.Id, cId);
                        if (courseWithResult != null)
                        {
                            MessageBox.Show(@"Student already have result", "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        var result = new ResultModel
                        {
                            SectionId = level.SectionModels.FirstOrDefault().Id,
                            CourseId  = cId,
                            StudentId = MatricNumber.Id,
                            Score     = int.Parse(nddScore.Value.ToString()),
                            CreatedAt = DateTime.UtcNow
                        };

                        ResultService.Create(result, 0);
                        MessageBox.Show($@"Result of {studentDetails} is saved", "Upload successfull", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(@"Ensure that LEVEL selected has a SESSION attached to it.", "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message.ToString(), ex);
                MessageBox.Show($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
Beispiel #10
0
 public static void UpdateUserTo(this AspNetUser target, AspNetUserModel source)
 {
     target.Address        = source.Address;
     target.Telephone      = source.Telephone;
     target.FirstName      = source.FirstName;
     target.LastName       = source.LastName;
     target.LockoutEnabled = source.LockoutEnabled;
 }
Beispiel #11
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                var level = LevelService.GetLevelId((string)ddlLevel2.SelectedValue);

                if (level.SectionModels != null && level.SectionModels.Count > 0)
                {
                    if (TextHelper.ContainsValue(new List <string>
                    {
                        beResultTemplate.Value
                    }))
                    {
                        lblError.Text = @"Result data is not selected";
                        return;
                    }

                    var dataRows = FileHelper.GetDataFromFile(beResultTemplate.Value);
                    var models   = new List <ResultSingleStudentTemplateDownloadModel>();

                    var rowIndex = 2;
                    foreach (var row in dataRows)
                    {
                        try
                        {
                            var institutionModel = new ResultSingleStudentTemplateDownloadModel()
                            {
                                CourseCode = row["CourseCode"].ToString(),
                                Score      = Convert.ToInt32(row["Score"].ToString()),
                            };
                            models.Add(institutionModel);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }

                    gridSingleStudentResult.DataSource = models;
                    _resultTemplateDownloadModels      = models;
                    MatricNumber = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
                    gridSingleStudentResult.Enabled             = true;
                    gridSingleStudentResult.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                    SemesterId = SemesterService.GetSemesterId((string)ddlSemester2.SelectedValue);
                    LevelId    = level.Id;
                }
                else
                {
                    MessageBox.Show(@"Ensure that LEVEL selected has a SESSION attached to it.", "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message.ToString(), ex);
                MessageBox.Show($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
        public static void CreateUser(AspNetUserModel model)
        {
            var authContext = new ApplicationDbContext();
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(authContext));

            var user = Mapper.Map <AspNetUserModel, ApplicationUser>(model);

            userManager.Create(user, model.Password);
            userManager.SetLockoutEnabled(user.Id, false);
            userManager.AddToRole(user.Id, model.RoleName);
        }
        private string UserName(string id)
        {
            string          result  = string.Empty;
            AspNetUserModel usuario = userService.GetSingle(u => u.Id == id);

            if (usuario != null)
            {
                result = usuario.FirstName;
            }
            return(result);
        }
Beispiel #14
0
 public async Task <HttpResponseMessage> Save(AspNetUserModel data)
 {
     try
     {
         await _iAspNetUser.SaveAsync(data);
     }
     catch (Exception ex)
     {
         Common.MyLogger.Error(ex.Message + ex.StackTrace + ex.InnerException.ToString());
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error"));
     }
     return(Request.CreateResponse(HttpStatusCode.OK, "Data Saved"));
 }
 public void Update(AspNetUserModel model, int currentAspNetUserId)
 {
     try
     {
         _unitOfWork.BeginTransaction();
         var userProfile = GetAspNetUserEntity(model.Id);
         Mapper.Map(model, userProfile);
         _repository.Update(userProfile);
         _unitOfWork.Commit();
     }
     catch (Exception ex)
     {
         _unitOfWork.Rollback();
         throw new Exception(ex.Message);
     }
 }
        private void RunValidation(AspNetUserModel model)
        {
            var emailExists = _aspNetUserRepository.Get().Any(c => c.Email == model.Email && c.Id != model.Id);

            if (emailExists)
            {
                throw new Exception("Sorry! This email already exists.");
            }

            var phoneExists = _aspNetUserRepository.Get().Any(c => c.PhoneNumber == model.PhoneNumber && c.Id != model.Id);

            if (phoneExists)
            {
                throw new Exception("Sorry! This phone number already exists.");
            }
        }
        // Fill
        public string FillAspNetUser(AspNetUser aspNetUser, AspNetUserModel aspNetUserModel)
        {
            aspNetUser.Id                   = aspNetUserModel.Id;
            aspNetUser.Email                = aspNetUserModel.LoginEmail;
            aspNetUser.EmailConfirmed       = aspNetUserModel.EmailConfirmed;
            aspNetUser.PasswordHash         = aspNetUserModel.PasswordHash;
            aspNetUser.SecurityStamp        = aspNetUserModel.SecurityStamp;
            aspNetUser.PhoneNumber          = aspNetUserModel.PhoneNumber;
            aspNetUser.PhoneNumberConfirmed = aspNetUserModel.PhoneNumberConfirmed;
            aspNetUser.TwoFactorEnabled     = aspNetUserModel.TwoFactorEnabled;
            aspNetUser.LockoutEndDateUtc    = aspNetUserModel.LockoutEndDateUtc;
            aspNetUser.LockoutEnabled       = aspNetUserModel.LockoutEnabled;
            aspNetUser.AccessFailedCount    = aspNetUserModel.AccessFailedCount;
            aspNetUser.UserName             = aspNetUserModel.LoginEmail;

            return("");
        }
Beispiel #18
0
        public async Task <ActionResult> SignUp(AspNetUserModel oModel)
        {
            oModel.UserName = oModel.Email;
            Utility oUtility = new Utility();

            oModel.RoleId   = Utility.MemberRoleId;
            oModel.RoleName = Utility.MemberRoleName;
            var user = new AspNetUser
            {
                UserName       = oModel.UserName,
                Email          = oModel.Email,
                Address        = oModel.Address,
                Telephone      = oModel.Telephone,
                FirstName      = oModel.FirstName,
                LastName       = oModel.LastName,
                UserComments   = string.Empty,
                LockoutEnabled = false
            };

            user.EmailConfirmed = true;
            if (!String.IsNullOrEmpty(oModel.Password))
            {
                var result = await UserManager.CreateAsync(user, oModel.Password);

                if (result.Succeeded)
                {
                    //Setting role
                    var roleManager = HttpContext.GetOwinContext().Get <ApplicationRoleManager>();
                    var roleName    = roleManager.FindById(oModel.RoleId).Name;
                    UserManager.AddToRole(user.Id, roleName);

                    //return PreparePayPalPayment(user);


                    // Add User Preferences for Dashboards Widgets

                    TempData["message"] = new MessageViewModel {
                        Message = "Please check your email for Confirmation", IsSaved = true
                    };
                    return(RedirectToAction("Index", "Home"));
                }
            }


            return(View(oModel));
        }
        // Check
        public string AspNetUserModelOK(AspNetUserModel aspNetUserModel)
        {
            string retStr = EmailOK(aspNetUserModel.LoginEmail);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            retStr = FieldCheckNotEmptyAndMaxLengthString(aspNetUserModel.Password, ServiceRes.Password, 100);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(retStr);
            }

            return("");
        }
        public AspNetUserModel PostUpdateAspNetUserDB(AspNetUserModel aspNetUserModel)
        {
            string retStr = AspNetUserModelOK(aspNetUserModel);

            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            //ContactOK contactOK = IsContactOK();
            //if (!string.IsNullOrEmpty(contactOK.Error))
            //    return ReturnError(contactOK.Error);

            AspNetUser aspNetUserToUpdate = GetAspNetUserWithIdDB(aspNetUserModel.Id);

            if (aspNetUserToUpdate == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.AspNetUser)));
            }

            retStr = FillAspNetUser(aspNetUserToUpdate, aspNetUserModel);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                return(ReturnError(retStr));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                retStr = DoUpdateChanges();
                if (!string.IsNullOrWhiteSpace(retStr))
                {
                    return(ReturnError(retStr));
                }

                LogModel logModel = _LogService.PostAddLogForObj("AppNetUsers", -1, LogCommandEnum.Change, aspNetUserToUpdate);
                if (!string.IsNullOrWhiteSpace(logModel.Error))
                {
                    return(ReturnError(logModel.Error));
                }

                ts.Complete();
            }

            return(GetAspNetUserModelWithEmailDB(aspNetUserToUpdate.Email));
        }
Beispiel #21
0
        //[SiteAuthorize(PermissionKey = "Profile")]
        public ActionResult Profile()
        {
            //AspNetUser result = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(User.Identity.GetUserId());
            //var ProfileViewModel = new ProfileViewModel
            //{
            //    Email = result.Email,
            //    UserName = result.UserName,
            //    Address = result.Address,
            //    ImageName = (result.ImageName != null && result.ImageName != string.Empty) ? result.ImageName : string.Empty,
            //    ImagePath = ConfigurationManager.AppSettings["ProfileImage"].ToString() + result.ImageName
            //};
            //ViewBag.FilePath = ConfigurationManager.AppSettings["ProfileImage"] + ProfileViewModel.ImageName;//Server.MapPath
            ViewBag.MessageVM = TempData["message"] as MessageViewModel;
            AspNetUserModel ProfileViewModel = new AspNetUserModel();

            ProfileViewModel = AspNetUserService.FindById(User.Identity.GetUserId()).CreateFrom();
            return(View(ProfileViewModel));
        }
Beispiel #22
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                LevelId    = LevelService.GetLevelId((string)ddlLevel.SelectedValue).Id;
                SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);
                Student    = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
                List <ResultSingleStudentTemplateDownloadModel> forSemester = ResultService.GetStudentResultForSemester(Student.Id, LevelId, SemesterId);

                gridSingleStudentResult.DataSource          = forSemester;
                gridSingleStudentResult.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message.ToString(), ex);
                this.ShowMessageBox($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
Beispiel #23
0
        private void Initialize()
        {
            var semesterItems = SemesterService.GetCount().OrderBy(c => c.Id).ToList();
            var levels        = LevelService.GetCount().OrderBy(c => c.Id).ToList();

            ddlSemester.DataSource = semesterItems.ToList().Select(c => c.Name);
            ddlLevel.DataSource    = levels.Select(c => c.Name);

            ddlMatricNumber.DataSource = AspNetUserService
                                         .GetCount(Enum.GetName(typeof(RolesConstants.Enum), RolesConstants.Enum.Student))
                                         .Select(c => c.MatricNumber);

            ddlLevel.SelectedIndexChanged    += (sender, args) => { LevelId = LevelService.GetLevelId((string)ddlLevel.SelectedValue).Id; };
            ddlSemester.SelectedIndexChanged += (sender, args) =>
            {
                SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);
            };
            ddlMatricNumber.SelectedIndexChanged += (sender, args) => { Student = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue); };
            LoadDataForResult();
        }
Beispiel #24
0
        private void btnLoadReport_Click(object sender, EventArgs e)
        {
            Student    = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
            LevelId    = LevelService.GetLevelId((string)ddlLevel.SelectedValue).Id;
            SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);


            var result = ResultService.StudentSemesterResult(Student.Id, LevelId, SemesterId);

            if (result == null)
            {
                this.ShowMessageBox("Can not load result at this time, please check selected values",
                                    "Error processing result", MessageBoxButtons.OK, RadMessageIcon.Error);

                return;
            }

            ReportDataSource studentDetails = new ReportDataSource("StudentDetails", new List <ReportStudentDetail>()
            {
                result.StudentDetail ?? new ReportStudentDetail(),
            });

            ReportDataSource reportStudentSemesterCourse = new ReportDataSource("ReportStudentSemesterCourse",
                                                                                result.SemesterCourse
                                                                                );

            ReportDataSource reportGradeDetail = new ReportDataSource("ReportGradeDetail",
                                                                      new List <ReportGradeDetail>()
            {
                result.GradeDetail ?? new ReportGradeDetail(),
            }
                                                                      );


            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(reportGradeDetail);
            reportViewer1.LocalReport.DataSources.Add(reportStudentSemesterCourse);
            reportViewer1.LocalReport.DataSources.Add(studentDetails);
            reportViewer1.RefreshReport();
        }
Beispiel #25
0
        public AspNetUserModel Update(AspNetUserModel entity)
        {
            int          cuid            = Convert.ToInt32(entity.CUserId);
            GEEDbContext objGEEDbContext = new GEEDbContext();
            var          UserData        = objGEEDbContext.AspNetUsers.Where(a => a.CUserId == cuid).FirstOrDefault();

            UserData.Email          = entity.Email;
            UserData.PasswordHash   = entity.PasswordHash;
            UserData.PhoneNumber    = entity.PhoneNumber;
            UserData.UserName       = entity.UserName;
            UserData.FirstName      = entity.FirstName;
            UserData.LastName       = entity.LastName;
            UserData.UserGroupId    = entity.UserGroupId;
            UserData.StuStaffTypeId = entity.StuStaffTypeId;
            objGEEDbContext.Entry(UserData).State = System.Data.Entity.EntityState.Modified;
            objGEEDbContext.Entry(UserData).Property(x => x.CUserId).IsModified = false;
            int i = objGEEDbContext.SaveChanges();

            return(new Model.Admin.AspNetUserModel {
                CUserId = i
            });
        }
Beispiel #26
0
        public static AspNetUserModel CreateFrom(this AspNetUser source)
        {
            AspNetUserModel oModel = new AspNetUserModel
            {
                Address = source.Address,
                //DateOfBirth = source.DateOfBirth,
                Email                = source.Email,
                FirstName            = source.FirstName,
                LastName             = source.LastName,
                Id                   = source.Id,
                ImageName            = source.ImageName,
                Telephone            = source.Telephone,
                UserName             = source.UserName,
                LockoutEnabled       = source.LockoutEnabled,
                LockoutEnabledString = source.LockoutEnabled ? "Yes" : "No",
                IsConfirmedString    = source.EmailConfirmed ? "Yes" : "No",
                RoleName             = source.AspNetRoles.Any() ? source.AspNetRoles.First().Name : "",
                RoleId               = source.AspNetRoles.Any() ? source.AspNetRoles.First().Id : ""
            };

            return(oModel);
        }
Beispiel #27
0
        //[SiteAuthorize(PermissionKey = "Profile")]
        public ActionResult Profile(AspNetUserModel profileViewModel)
        {
            AspNetUser result = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(User.Identity.GetUserId());

            //Updating Data
            try
            {
                result.FirstName = profileViewModel.FirstName;
                result.LastName  = profileViewModel.LastName;
                result.Telephone = profileViewModel.Telephone;
                result.Address   = profileViewModel.Address;
                var updationResult = UserManager.Update(result);
                updateSessionValues(result);
                TempData["message"] = new MessageViewModel {
                    Message = "Profile has been updated", IsUpdated = true
                };
            }
            catch (Exception e)
            {
            }
            return(RedirectToAction("Profile"));
        }
Beispiel #28
0
        public AllCourseStudent()
        {
            InitializeComponent();

            var semesterItems = SemesterService.GetCount().OrderBy(c => c.Id).ToList();
            var levels        = LevelService.GetCount().OrderBy(c => c.Id).ToList();

            ddlSemester.DataSource = semesterItems.ToList().Select(c => c.Name);
            ddlLevel.DataSource    = levels.Select(c => c.Name);

            gridSingleStudentResult.Enabled = false;

            ddlMatricNumber.DataSource = AspNetUserService
                                         .GetCount(Enum.GetName(typeof(RolesConstants.Enum), RolesConstants.Enum.Student))
                                         .Select(c => c.MatricNumber);

            ddlLevel.SelectedIndexChanged    += (sender, args) => { LevelId = LevelService.GetLevelId((string)ddlLevel.SelectedValue).Id; };
            ddlSemester.SelectedIndexChanged += (sender, args) =>
            {
                SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);
            };
            ddlMatricNumber.SelectedIndexChanged += (sender, args) => { Student = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue); };
        }
Beispiel #29
0
 public bool NameExist(AspNetUserModel user)
 {
     return(Table.Any(x => x.UserName.Equals(user.UserName) && user.Id != x.Id));
 }
 public IHttpActionResult Put([FromBody] AspNetUserModel model)
 {
     userService.Update(model);
     return(Ok());
 }