Exemple #1
0
        public ActionResult MyProfile()
        {
            // get logged in user
            var user = context.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

            // get logged in user profile
            var userprofile = context.UserProfile.Where(x => x.UserID == user.ID).FirstOrDefault();

            // create AdminProfileViewModel
            AdminProfileViewModel adminProfileViewModel = new AdminProfileViewModel();

            adminProfileViewModel.FirstName = user.FirstName;
            adminProfileViewModel.LastName  = user.LastName;
            adminProfileViewModel.Email     = user.EmailID;
            adminProfileViewModel.PhoneNumberCountryCode = userprofile.PhoneNumberCountryCode;
            adminProfileViewModel.PhoneNumber            = userprofile.PhoneNumber;

            if (userprofile.SecondaryEmailAddress != null)
            {
                adminProfileViewModel.SecondaryEmail = userprofile.SecondaryEmailAddress;
            }

            if (userprofile.ProfilePicture != null)
            {
                adminProfileViewModel.ProfilePictureUrl = userprofile.ProfilePicture;
            }

            // get country code list
            adminProfileViewModel.CountryCodeList = context.Countries.Where(x => x.IsActive).OrderBy(x => x.CountryCode).Select(x => x.CountryCode).ToList();

            return(View(adminProfileViewModel));
        }
Exemple #2
0
        public ActionResult Profile()
        {
            string username = HttpContext.User.Identity.Name;
            AdminProfileViewModel profileVm = this.userService.GetAdminProfileViewModel(username);

            return(this.View(profileVm));
        }
        public async Task <IdentityResult> CreateAdmin(AdminProfileViewModel user)
        {
            var newUser = new User()
            {
                UserName    = user.UserName,
                PhoneNumber = user.PhoneNumber,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Email       = user.UserName,
                Status      = "Active"
            };
            var result = await _userManager.CreateAsync(newUser, _appSettings.Value.DefaultPassword);

            if (result.Succeeded)
            {
                await _userManager.AddToRoleAsync(newUser, "Admin");

                var code = await _userManager.GenerateEmailConfirmationTokenAsync(newUser);

                await _userManager.ConfirmEmailAsync(newUser, code);

                if (user.SuperAdmin)
                {
                    await _userManager.AddToRoleAsync(newUser, "SuperAdmin");
                }
            }

            return(result);
        }
        // GET: AdminProfile
        public ActionResult Profiles()
        {
            if (Session["ID"] != null)
            {
                int  id         = Convert.ToInt32(Session["ID"]);
                int  RoleMember = Convert.ToInt32(Enums.UserRoleId.Member);
                User user       = db.Users.Where(x => x.ID == id).FirstOrDefault();
                if (user.RoleID != RoleMember)
                {
                    AdminProfileViewModel Model = new AdminProfileViewModel();
                    Model.countries = db.Countries.Where(x => x.IsActive == true).ToList();

                    User userModel = db.Users.Where(x => x.ID == id).FirstOrDefault();

                    Model.user = userModel;

                    return(View(Model));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
        public ActionResult LeaveDetail(AdminReplyViewModel adminReply)
        {
            var employee = (AdminProfileViewModel)Session["EmployeeObj"];

            leaveRequestService.UpdateStatusAndResponse(adminReply.LeaveStatus, adminReply.Response, adminReply.RequestID, employee.EmployeeID);

            SmtpClient smtp = new SmtpClient("smtp.gmail.com");

            smtp.EnableSsl = true;
            smtp.Port      = 587;


            smtp.Credentials = new NetworkCredential("*****@*****.**",
                                                     "tvokfhzelmfawwel");
            AdminProfileViewModel empProfile = employeeService.GetEmployeeByID(adminReply.CreatedBy);

            if (adminReply.LeaveStatus == "Accept")
            {
                smtp.Send("*****@*****.**", empProfile.EmailID,
                          "Your Leave Status", "Hi " + empProfile.FirstName + " " + empProfile.MiddleName + " " + empProfile.LastName + "," + "\n\n\nYour leave request approved.");
            }
            else
            {
                smtp.Send("*****@*****.**", empProfile.EmailID,
                          "Your Leave Status", "Hi " + empProfile.FirstName + " " + empProfile.MiddleName + " " + empProfile.LastName + "," + "\n\n\nYour leave request rejected.");
            }

            return(RedirectToAction("Verifyleave"));
        }
Exemple #6
0
        public IActionResult Put(string id, [FromBody] AdminProfileViewModel model)
        {
            var admin = _userManager.FindByIdAsync(id).Result;

            if (admin == null)
            {
                return(NotFound());
            }

            admin.FirstName   = model.FirstName;
            admin.LastName    = model.LastName;
            admin.City        = model.City;
            admin.Address     = model.Address;
            admin.Email       = model.Email;
            admin.PhoneNumber = model.PhoneNo;
            admin.AboutYou    = model.AboutYou;

            var result = _userManager.UpdateAsync(admin).Result;

            if (!result.Succeeded)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public ActionResult LeaveStatus()
        {
            AdminProfileViewModel           profile         = (AdminProfileViewModel)Session["EmployeeObj"];
            List <RequestVacationViewModel> requestVacation = new List <RequestVacationViewModel>();

            requestVacation = null;
            requestVacation = leaveRequestService.GetAllRequestByRequesterId(profile.EmployeeID);
            if (requestVacation.Count() != 0)
            {
                foreach (var item in requestVacation)
                {
                    if (item.ApproverID != 0)
                    {
                        AdminProfileViewModel employee = employeeService.GetEmployeeByID(item.ApproverID);
                        item.ApproverName = employee.FirstName + " " + employee.MiddleName + " " + employee.LastName;
                    }

                    VacationTypeViewModel vacationType = vacationTypeService.GetVacationTypeByVacationId(item.VacationTypeID);
                    item.VacationName = vacationType.VacationName;
                }
                return(View(requestVacation));
            }

            return(RedirectToAction("Leavestatus"));
        }
        public IActionResult Index(AdminProfileViewModel model)
        {
            var OnlineUser = _userManager.GetUserAsync(HttpContext.User).Result;


            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (OnlineUser != null && _userManager.IsInRoleAsync(OnlineUser, "Admin").Result)
            {
                OnlineUser.FirstName   = model.FirstName;
                OnlineUser.LastName    = model.LastName;
                OnlineUser.Email       = model.Email;
                OnlineUser.Address     = model.Address;
                OnlineUser.Aboutyou    = model.Aboutyou;
                OnlineUser.PhoneNumber = model.PhoneNo;
            }

            var result = _userManager.UpdateAsync(OnlineUser).Result;

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", new { area = "Admin", controller = "AdminProfile" }));
            }
            return(View());
        }
        public async Task <bool> EditAdmin(AdminProfileViewModel vm)
        {
            try
            {
                var dbUser = await _userManager.FindByIdAsync(vm.Id);

                if (vm.SuperAdmin == false)
                {
                    await _userManager.RemoveFromRoleAsync(dbUser, "SuperAdmin");
                }
                else
                {
                    await _userManager.AddToRoleAsync(dbUser, "SuperAdmin");
                }

                Mapper.Map(vm, dbUser);
                await _userManager.SetEmailAsync(dbUser, vm.UserName);

                _context.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError("Could not get all faculty", ex);
                return(false);
            }
        }
Exemple #10
0
 public ActionResult AddNewEmployee(AdminProfileViewModel obj)
 {
     if (ModelState.IsValid)
     {
         if (Request.Files.Count >= 1)
         {
             var File    = Request.Files[0];
             var ImgByte = new Byte[File.ContentLength + 10];
             File.InputStream.Read(ImgByte, 0, File.ContentLength);
             var Base64String = Convert.ToBase64String(ImgByte, 0, ImgByte.Length);
             obj.Image = Base64String;
         }
         obj.GenderID        = Convert.ToInt32(obj.GenderStringId);
         obj.DepartmentID    = Convert.ToInt32(obj.DepartmentStringId);
         obj.DesignationID   = Convert.ToInt32(obj.DesignationStringId);
         obj.QualificationID = Convert.ToInt32(obj.QualificationStringId);
         obj.ExperienceID    = experienceService.GetLatestExperienceID() + 1;
         employeeService.SetNewEmployee(obj);
         return(RedirectToAction("employee"));
     }
     else
     {
         ModelState.AddModelError("newemployee", "Invalid employee details, please check and try again");
         return(RedirectToAction("addnewemployee"));
     }
 }
Exemple #11
0
        // GET -- Admin Profile Action - Display Admin registration Detail
        public async Task <IActionResult> AdminProfile(string id)
        {
            var profile = await _applicationUser.GetAdminById(id);

            var role = _applicationUser.GetRole(id);

            if (profile == null)
            {
                return(View());
            }
            var model = new AdminProfileViewModel
            {
                Id                = profile.Id,
                FirstName         = profile.FirstName,
                LastName          = profile.LastName,
                Email             = profile.Email,
                PhoneNumber       = profile.PhoneNumber,
                Address           = profile.Address,
                BirthDate         = profile.BirthDate,
                Gender            = profile.Gender,
                NumberOfChildren  = profile.NumberOfChildren,
                MaritalStatus     = profile.MaritalStatus,
                Role              = role,
                ProfilePictureUrl = profile.ProfilePictureUrl,
                AdminPasscode     = profile.AdminPasscode
            };

            return(View(model));
        }
        public ActionResult UpdatePassword()
        {
            UpdatePasswordViewModel updatePasswordViewModel = new UpdatePasswordViewModel();
            AdminProfileViewModel   adminProfileViewModel   = (AdminProfileViewModel)Session["EmployeeObj"];

            updatePasswordViewModel.EmployeeID = adminProfileViewModel.EmployeeID;
            return(View(updatePasswordViewModel));
        }
Exemple #13
0
        public JsonResult IsMailExist(string password, string email)
        {
            bool isExist = false;
            AdminProfileViewModel employee = employeeService.GetEmployeeByEmailAndPassword(email, password);

            if (employee != null)
            {
                isExist = true;
            }
            return(Json(isExist, JsonRequestBehavior.AllowGet));
        }
Exemple #14
0
        public ActionResult ChangeVirtualHead(int Id)
        {
            AdminProfileViewModel        existingVH   = employeeService.GetEmployeeByID(Id);
            List <AdminProfileViewModel> employeeList = employeeService.GetEmployeeByDepartmentID(existingVH.DepartmentID);

            AdminProfileViewModel newVitualHead = new AdminProfileViewModel();

            existingVH.EmployeeList = employeeService.GetAllEmployeeOfDepartment(employeeList);

            return(View(existingVH));
        }
Exemple #15
0
 public async Task <IActionResult> EditAdmin(AdminProfileViewModel vm)
 {
     if (ModelState.IsValid)
     {
         if (await _repository.EditAdmin(vm))
         {
             return(RedirectToAction("Admins"));
         }
     }
     return(View(vm));
 }
        public async Task <IActionResult> AdminProfile(AdminProfileViewModel adminProfileViewModel)
        {
            var adminUser = await _userManager.FindByIdAsync(adminProfileViewModel.AdminUserId);

            adminUser.UserName    = adminProfileViewModel.Name;
            adminUser.Email       = adminProfileViewModel.Email;
            adminUser.PhoneNumber = adminProfileViewModel.PhoneNumber;
            await _userManager.UpdateAsync(adminUser);

            adminProfileViewModel.Name        = adminUser.UserName;
            adminProfileViewModel.Email       = adminUser.Email;
            adminProfileViewModel.PhoneNumber = adminUser.PhoneNumber;
            return(View(adminProfileViewModel));
        }
        private Task <AdminProfileViewModel> GetItemsAsync()
        {
            var model      = new AdminProfileViewModel();
            var OnlineUser = _userManager.GetUserAsync(HttpContext.User).Result;

            if (OnlineUser != null && _userManager.IsInRoleAsync(OnlineUser, "Admin").Result)
            {
                model.FirstName   = OnlineUser.FirstName;
                model.LastName    = OnlineUser.LastName;
                model.Email       = OnlineUser.Email;
                model.AvatarImage = OnlineUser.AvatarImage;
            }
            return(Task.FromResult(model));
        }
Exemple #18
0
        public ActionResult AdminProfile()
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            var AdminViewObj = new AdminProfileView((int)Session["userId"]);
            var viewModel    = new AdminProfileViewModel
            {
                Admin = AdminViewObj.GetAdminProfile()
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> AdminProfile()
        {
            System.Security.Claims.ClaimsPrincipal currentUser = this.User;
            bool IsAdmin = currentUser.IsInRole("Admin");
            var  id      = _userManager.GetUserId(User); // Get user id:

            var user = await _userManager.FindByIdAsync(id);

            var adminProfileViewModel = new AdminProfileViewModel();

            adminProfileViewModel.Name        = user.UserName;
            adminProfileViewModel.AdminUserId = user.Id;
            adminProfileViewModel.Email       = user.Email;
            adminProfileViewModel.PhoneNumber = user.PhoneNumber;
            return(View(adminProfileViewModel));
        }
Exemple #20
0
        public AdminProfileViewModel GetEmployeeByEmailAndPassword(string Email, string Password)
        {
            Employee employee = er.GetEmployeeByEmailAndPassword(Email, Password);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Employee, AdminProfileViewModel>();
                cfg.CreateMap <Department, DepartmentViewModel>();

                cfg.IgnoreUnmapped();
            });
            IMapper mapper = config.CreateMapper();
            AdminProfileViewModel adminProfileViewModel = mapper.Map <Employee, AdminProfileViewModel>(employee);

            return(adminProfileViewModel);
        }
        public ActionResult LeaveDetail(int Id)     //show each emp leave details for admin
        {
            RequestVacationViewModel requestVacation = leaveRequestService.GetLeaveRequestByRequestID(Id);
            AdminProfileViewModel    employee        = employeeService.GetEmployeeByID(requestVacation.CreatedBy);

            requestVacation.RequesterName = employee.FirstName + " " + employee.MiddleName + " " + employee.LastName;
            DesignationViewModel designation = designationService.GetDesignationByDesignationID(employee.DesignationID);

            requestVacation.RequesterDesignation = designation.DesignationName;

            VacationTypeViewModel vacationType = vacationTypeService.GetVacationTypeByVacationId(requestVacation.VacationTypeID);

            requestVacation.VacationName = vacationType.VacationName;


            return(View(requestVacation));
        }
Exemple #22
0
        public AdminProfileViewModel GetEmployeeByID(int EmployeeID)
        {
            Employee employee = er.GetEmployeeByID(EmployeeID);
            AdminProfileViewModel adminProfileView = null;
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Employee, AdminProfileViewModel>();
                cfg.CreateMap <Department, DepartmentViewModel>();

                cfg.IgnoreUnmapped();
            });
            IMapper mapper = config.CreateMapper();

            adminProfileView = mapper.Map <Employee, AdminProfileViewModel>(employee);

            return(adminProfileView);
        }
Exemple #23
0
        public async Task <IActionResult> CreateAdmin(AdminProfileViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }


            var result = await _repository.CreateAdmin(vm);

            if (!result.Succeeded)
            {
                AddErrors(result);
                return(View());
            }

            return(RedirectToAction("Admins"));
        }
        public void Test_GetAdminProfileVm_Shold_Return_Vm()
        {
            // Arrange
            const string username  = "******";
            const string firstName = "Niki";
            const string lastName  = "Dutskinov";
            DateTime     birthDate = new DateTime(1995, 11, 06);

            // Act
            AdminProfileViewModel profileVm = this.usersService
                                              .GetAdminProfileViewModel(username);

            // Assert
            Assert.IsNotNull(profileVm);
            Assert.AreEqual(username, profileVm.UserName);
            Assert.AreEqual(firstName, profileVm.FirstName);
            Assert.AreEqual(lastName, profileVm.LastName);
            Assert.AreEqual(birthDate, profileVm.BirthDate);
        }
Exemple #25
0
        public void SetNewEmployee(AdminProfileViewModel obj)
        {
            obj.Password = SHA256HashGenerator.GenerateHash(obj.Password);
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <AdminProfileViewModel, Employee>();

                cfg.CreateMap <AdminProfileViewModel, Experience>();


                cfg.IgnoreUnmapped();
            });
            IMapper mapper = config.CreateMapper();

            Employee ed = mapper.Map <AdminProfileViewModel, Employee>(obj);

            Experience exp = mapper.Map <AdminProfileViewModel, Experience>(obj);

            er.SetNewEmployee(ed, exp);
        }
Exemple #26
0
        public ActionResult AdminEditEmployee(int id)
        {
            AdminProfileViewModel adminProfileView = employeeService.GetEmployeeByID(id);
            var gender = genderService.GetAllGender();

            adminProfileView.GenderList = genderService.GetSelectListItemsGender(gender);

            var qualification = qualificationService.GetAllQualification();

            adminProfileView.QualificationList = qualificationService.GetSelectListItemQualification(qualification);

            var designation = designationService.GetAllDesignation();

            adminProfileView.DesignationList = designationService.GetSelectListItemDesignation(designation);

            var department = departmentService.GetAllDepartment();

            adminProfileView.DepartmentList = departmentService.GetSelectListItemsDepartment(department);
            return(View(adminProfileView));
        }
Exemple #27
0
        private AdminProfileViewModel GetAdminProfileViewModel(User admin)
        {
            var adminViewModel = new AdminProfileViewModel();

            adminViewModel.TotalUsers    = UserService.GetUsers().Count;
            adminViewModel.StudentNumber = UserService.GetUsersByRole(RoleNames.STUDENT).Count;
            adminViewModel.TeacherNumber = UserService.GetUsersByRole(RoleNames.TEACHER).Count;
            adminViewModel.AdminNumber   = UserService.GetUsersByRole(RoleNames.ADMIN).Count;

            adminViewModel.LocationsNumber            = LocationService.GetAllLocations().Count;
            adminViewModel.LocationTypesNumber        = LocationService.GetAllLocationTypes().Count;
            adminViewModel.ResourcesNumber            = ResourceService.GetAllResources().GetData().Count();
            adminViewModel.AverageResourcePerLocation = (adminViewModel.ResourcesNumber / (double)adminViewModel.LocationsNumber);

            adminViewModel.QuizesNumber             = TeacherQuizesService.GetAllQuizes().GetData().Count();
            adminViewModel.QuestionsNumber          = TeacherQuizesService.GetAllQuizQuestions().GetData().Count();
            adminViewModel.StudentTakenQuizesNumber = TeacherQuizesService.GetAllStudentResults().GetData().Count();

            return(adminViewModel);
        }
Exemple #28
0
 public ActionResult AdminUserProfile()
 {
     if (Session["userId"] == null)
     {
         return(Redirect("~"));
     }
     if (TempData["Id"] == null)
     {
         return(RedirectToAction("Admins"));
     }
     else
     {
         var AdminViewObj = new AdminProfileView((int)TempData["Id"]);
         var viewModel    = new AdminProfileViewModel
         {
             Admin = AdminViewObj.GetAdminProfile()
         };
         return(View(viewModel));
     }
 }
 public new ActionResult Profile(AdminProfileViewModel adminProfileViewModel)
 {
     adminProfileViewModel = new AdminProfileViewModel()
     {
         Id         = 1,
         FullName   = "Dani Daniels",
         Email      = "*****@*****.**",
         Address    = "West town, Canada",
         Age        = 24,
         BloogGroup = "O+",
         Gender     = "Female",
         Image      = "http://www.facebook.com",
         Location   = "Kuril Kuratoli",
         NewFee     = 800,
         OldFee     = 500,
         Phone      = "01521434331",
         Specialist = "none"
     };
     return(View(model: adminProfileViewModel));
 }
Exemple #30
0
        public async Task <IActionResult> GetProfile()
        {
            AdminProfileViewModel model = new AdminProfileViewModel();
            var userId     = _caller.Claims.Single(c => c.Type == "id");
            var OnlineUser = await _userManager.FindByIdAsync(userId.Value);

            var base64 = Convert.ToBase64String(OnlineUser.Avatarimage);
            var imgsrc = string.Format("data:image/gif;base64,{0}", base64);

            model.Id        = OnlineUser.Id;
            model.FirstName = OnlineUser.FirstName;
            model.LastName  = OnlineUser.LastName;
            model.Email     = OnlineUser.Email;
            model.Address   = OnlineUser.Address;
            model.AboutYou  = OnlineUser.AboutYou;
            model.PhoneNo   = OnlineUser.PhoneNumber;
            model.City      = OnlineUser.City;
            model.Image     = imgsrc;

            return(new ObjectResult(model));
        }