public HttpResponseMessage SaveFullProfileInfo(HttpRequestMessage request, EmployeeProfileViewModel profileModel) { var employee = new Employee { EmployeeId = profileModel.EmployeeId, FullName = profileModel.FullName, Email = profileModel.Email, Address = profileModel.Address, Gender = profileModel.Gender, Birthday = new DateTimeOffset(profileModel.Birthday), MobilePhone = profileModel.MobilePhone, Phone = profileModel.Phone, Department = new Department() { DepartmentId = profileModel.DepartmentId }, Title = profileModel.Title }; _employeeProfileRepository.UpdateFullProfileInfo(employee); var response = request.CreateResponse(HttpStatusCode.OK); return(response); }
public EmployeeProfileViewModel GetEmployeeProfileData(int EmployeeID) { EmployeeProfileViewModel e = new EmployeeProfileViewModel(); var EmployeeDetails = (from ed in DBContext.Employees where ed.EmployeeID == EmployeeID select ed).SingleOrDefault(); var data = (from ed in DBContext.Referrals join ed1 in DBContext.Jobs on ed.JobID equals ed1.JobID join ed3 in DBContext.Status on ed.StatusID equals ed3.StatusID where ed.EmployeeID == EmployeeID select new ReferralDataViewModel { CandidateName = ed.CandidateName, PhoneNumber = ed.PhoneNumber, JobID = ed.JobID, Experience = ed.Experience, Bonus = ed1.Bonus, Status = ed3.StatusName, Post = ed1.Post, ReferralID = ed.ReferralID, }); e.referraldetails = data.ToList(); e.employeedetails.Name = EmployeeDetails.FirstName + (string.IsNullOrEmpty(EmployeeDetails.MiddleName) ? "" : EmployeeDetails.MiddleName) + " " + EmployeeDetails.LastName; e.employeedetails.PhoneNumber = EmployeeDetails.PhoneNumber; e.employeedetails.Designation = EmployeeDetails.Designation; e.employeedetails.Email = EmployeeDetails.Email; e.employeedetails.Bonus = Convert.ToInt16(EmployeeDetails.ReferralBonus); e.employeedetails.Score = Convert.ToInt16(EmployeeDetails.ReferralsConverted); return(e); }
public ActionResult Update(string id) { var userId = User.Identity.GetUserId(); var milites = GetMilitaries(); var profile = _context.Employees.Where(e => e.Id == id && id == userId).FirstOrDefault(); if (profile == null) { return(RedirectToAction("Create", "Employees")); } var viewModel = new EmployeeProfileViewModel { FirstName = profile.FirstName, LastName = profile.LastName, birthDate = profile.birthDate, Year = profile.Year, Month = profile.Month, Day = profile.Day, Gender = profile.Gender, MaritalStatus = profile.MaritalStatus, MilitaryStatus = profile.MilitaryStatus, ProfileImage = profile.ProfileImage, Militaries = GetSelectListItems(milites) }; return(View(viewModel)); }
public ActionResult Create() { //ViewBag.MilitaryStatus = new SelectList(new[] // {"Not Applicable", // "Exempted", // "Completed", // "Postponed" }); var userId = User.Identity.GetUserId(); var CheckIfUserIsEmployee = _context.Users.Where(u => u.Id == userId && u.RoleId == 1).FirstOrDefault(); var CheckIfEmployeeHasProfile = _context.Employees.Where(e => e.Id == userId).FirstOrDefault(); if (CheckIfEmployeeHasProfile == null && CheckIfUserIsEmployee != null) { var milits = GetMilitaries(); var viewModel = new EmployeeProfileViewModel(); viewModel.Militaries = GetSelectListItems(milits); return(View(viewModel)); } return(Content("you have already create a profile! ")); }
public void UpdateEmployeeProfile(EmployeeProfileViewModel evm) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <EmployeeProfileViewModel, Employee>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); Employee e = mapper.Map <EmployeeProfileViewModel, Employee>(evm); hr.UpdateEmployeeProfile(e); }
public EmployeeProfileViewModel ViewEmployeeProfile(int eid) { Employee e = er.ViewEmployeeProfile(eid); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Employee, EmployeeProfileViewModel>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); EmployeeProfileViewModel evm = mapper.Map <Employee, EmployeeProfileViewModel>(e); return(evm); }
public ActionResult Update(EmployeeProfileViewModel viewModel, HttpPostedFileBase upload) { if (ModelState.IsValid) { if (upload != null) { string oldPath = viewModel.ProfileImage; if (oldPath != null) { System.IO.File.Delete(oldPath); } string path = Path.Combine(Server.MapPath("~/Images/Employees"), upload.FileName); upload.SaveAs(path); viewModel.ProfileImage = upload.FileName; } } // _context.Entry(viewModel).State = EntityState.Modified; var profile = _context.Employees.Single(e => e.Id == viewModel.Id); profile.FirstName = viewModel.FirstName; profile.LastName = viewModel.LastName; profile.birthDate = new DateTime(viewModel.Year, viewModel.Month, viewModel.Day); profile.Year = viewModel.Year; profile.Month = viewModel.Month; profile.Day = viewModel.Day; profile.Gender = viewModel.Gender; profile.MaritalStatus = viewModel.MaritalStatus; profile.MilitaryStatus = viewModel.MilitaryStatus; profile.ProfileImage = viewModel.ProfileImage; _context.SaveChanges(); viewModel.Militaries = GetSelectListItems(GetMilitaries()); return(RedirectToAction("GetAll")); //var profile = _context.Employees.Single(e => e.Id == viewModel.Id); //profile.FirstName = viewModel.FirstName; //profile.LastName = viewModel.LastName; //profile.BirthDate = viewModel.BirthDate; //profile.Year = viewModel.Year; //profile.Month = viewModel.Month; //profile.Day = viewModel.Day; //profile.Gender = viewModel.Gender; //profile.MaritalStatus = viewModel.MaritalStatus; //profile.MilitaryStatus = viewModel.MilitaryStatus; //profile.ProfileImage = viewModel.ProfileImage; //return View(viewModel); }
public IActionResult Index() { EmployeeProfileViewModel vmObj = new EmployeeProfileViewModel { EmployeeCard = new employeecard(), LeaveBalances = new List <leavebalance>() }; try { vmObj.EmployeeCard = Employeecard_PortClientService() .ReadAsync(User.Identity.GetEmployeeNo()) .GetAwaiter() .GetResult() .employeecard; leavebalance_Filter[] filter = { new leavebalance_Filter { Field = leavebalance_Fields.Employee_Code, Criteria = User.Identity.GetEmployeeNo() } }; vmObj.LeaveBalances = Leavebalance_PortClientService() .ReadMultipleAsync(filter, "", 0) .GetAwaiter() .GetResult() .ReadMultiple_Result1 .ToList(); GetEmployeePictureweb pictureWeb = new GetEmployeePictureweb { empNo = User.Identity.GetEmployeeNo(), picture = "" }; vmObj.EmployeeImage = Hrmgt_PortClientService() .GetEmployeePicturewebAsync(pictureWeb) .GetAwaiter() .GetResult() .picture; } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(View(vmObj)); }
// GET: EmployeeProfile public ActionResult EmployeeProfile() { var userId = User.Identity.GetUserId(); Employee employee = _employeeManager.GetByUserId(userId); if (employee == null) { return(HttpNotFound()); } EmployeeProfileViewModel employeeProfile = Mapper.Map <EmployeeProfileViewModel>(employee); return(View(employeeProfile)); }
public ActionResult Edit(EmployeeProfileViewModel editModel) { if (!ModelState.IsValid) { ViewBag.Skills = GetCategories(); return(View(editModel)); } string employeeId = User.Identity.GetUserId(); _employeeService.EditEmployeeProfile(employeeId, editModel.Age, editModel.AboutMe, editModel.SelectedSkills); _commitProvider.SaveChanges(); return(Redirect(Request.UrlReferrer.PathAndQuery)); }
public ActionResult Create(EmployeeProfileViewModel createModel) { if (!ModelState.IsValid) { ViewBag.Skills = GetCategories(); return(View(createModel)); } string userId = User.Identity.GetUserId(); _employeeService.CreateEmployeeProfile(userId, createModel.Age, createModel.AboutMe, createModel.SelectedSkills); _commitProvider.SaveChanges(); return(RedirectToAction("settings", "account")); }
// GET: Employees/ProfileDelete/5 public ActionResult EmployeeProfileDelete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee employee = _employeeManager.GetById((int)id); if (employee == null) { return(HttpNotFound()); } EmployeeProfileViewModel employeeProfileViewModel = Mapper.Map <EmployeeProfileViewModel>(employee); return(View(employeeProfileViewModel)); }
public ActionResult EmployeeProfileEdit([Bind(Include = "Id,Name,EmployeeDesignationId,DepartmentId,ContactNo,Address")] EmployeeProfileViewModel employeeProfileViewModel) { if (ModelState.IsValid) { Employee employee = Mapper.Map <Employee>(employeeProfileViewModel); var userId = User.Identity.GetUserId(); employee.UserId = userId; _employeeManager.Update(employee); TempData["Message"] = "Profile update successfully!"; return(RedirectToAction("EmployeeProfile", "Employees")); } ViewBag.DepartmentId = new SelectList(_departmentManager.GetAll(), "Id", "Name", employeeProfileViewModel.DepartmentId); if (ViewBag.DepartmentId != null) { ViewBag.EmployeeDesignationId = new SelectList(_employeeDesignationManager.GetByDepartmentId(employeeProfileViewModel.DepartmentId), "Id", "Designation", employeeProfileViewModel.EmployeeDesignationId); } return(View(employeeProfileViewModel)); }
public ActionResult Create(EmployeeProfileViewModel viewModel, HttpPostedFileBase upload) { var milits = GetMilitaries(); viewModel.Militaries = GetSelectListItems(milits); var userId = User.Identity.GetUserId(); var employeeProfile = _context.Employees.Include(e => e.User).Where(e => e.Id == userId).FirstOrDefault(); if (ModelState.IsValid && employeeProfile == null) { string path = Path.Combine(Server.MapPath("~/Images/Employees"), upload.FileName); upload.SaveAs(path); var employee = new Employee { Id = userId, FirstName = viewModel.FirstName, LastName = viewModel.LastName, birthDate = new DateTime(viewModel.Year, viewModel.Month, viewModel.Day), Year = viewModel.Year, Month = viewModel.Month, Day = viewModel.Day, MaritalStatus = viewModel.MaritalStatus, MilitaryStatus = viewModel.MilitaryStatus, Gender = viewModel.Gender, ProfileImage = upload.FileName, UserId = userId }; _context.Employees.Add(employee); _context.SaveChanges(); ViewBag.UserProfile = null; ViewBag.comProfile = null; ViewBag.empProfile = employeeProfile; return(RedirectToAction("Index", "Home")); } return(View(viewModel)); }
public IHttpActionResult GetEmployeeProfile([FromUri] string UserId) { var viewModel = new EmployeeProfileViewModel(); var UserTable = _context.Users.Where(u => u.Id == UserId).Single(u => u.Id == UserId); var VenueName = _context.UserVenues.Include("Venues").Where(v => v.UserId == UserId).FirstOrDefault(v => v.UserId == UserId).Venues.VenueName; var ServicesRaw = (from u in _context.UserServices join s in _context.subCategories on u.subCategoriesId equals s.Id where u.UserId == UserId select new { s.Id, s.SubCatDesc }).ToList(); List <SubCategories> subCategories = new List <SubCategories>(); foreach (var obj in ServicesRaw) { SubCategories sub = new SubCategories { Id = obj.Id, SubCatDesc = obj.SubCatDesc }; subCategories.Add(sub); } var FullName = UserTable.FullName; var UserName = UserTable.UserName; var Email = UserTable.Email; var PhoneNo = UserTable.PhoneNumber; var ImagePath = UserTable.ImagePath; viewModel.FullName = FullName; viewModel.Email = Email; viewModel.ImagePath = ImagePath; viewModel.PhoneNumber = PhoneNo; viewModel.UserName = UserName; viewModel.VenueName = VenueName; viewModel.Services.AddRange(subCategories); return(Ok(viewModel)); }
public ActionResult Edit() { string userId = User.Identity.GetUserId(); var employeeProfile = _employeeService.FindEmployee(userId); if (employeeProfile == null) { return(View("Error")); } var editModel = new EmployeeProfileViewModel() { Age = employeeProfile.Age, AboutMe = employeeProfile.AboutMe }; editModel.SelectedSkills = employeeProfile.Skills.Select(p => p.Id).ToArray(); ViewBag.Skills = GetCategories(); return(View(editModel)); }
public HttpResponseMessage GetProfileInfo(HttpRequestMessage request) { var employeeId = CurrentUserId; var employee = _employeeProfileRepository.Get(employeeId); var viewModel = new EmployeeProfileViewModel { EmployeeId = employee.EmployeeId, FullName = employee.FullName, Email = employee.Email, Address = employee.Address, Gender = employee.Gender, Birthday = employee.Birthday == null ? new DateTime(1900, 1, 1) : employee.Birthday.Value.Date, MobilePhone = employee.MobilePhone, Phone = employee.Phone, Title = employee.Title, Department = employee.Department == null ? string.Empty : employee.Department.Name, DepartmentId = employee.Department == null ? 0 : employee.Department.DepartmentId }; return(request.CreateResponse(HttpStatusCode.OK, viewModel)); }
// GET: Employees/ProfileEdit/5 public ActionResult EmployeeProfileEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee employee = _employeeManager.GetById((int)id); if (employee == null) { return(HttpNotFound()); } EmployeeProfileViewModel employeeProfileViewModel = Mapper.Map <EmployeeProfileViewModel>(employee); ViewBag.DepartmentId = new SelectList(_departmentManager.GetAll(), "Id", "Name", employeeProfileViewModel.DepartmentId); if (ViewBag.DepartmentId != null) { ViewBag.EmployeeDesignationId = new SelectList(_employeeDesignationManager.GetByDepartmentId(employeeProfileViewModel.DepartmentId), "Id", "Designation", employeeProfileViewModel.EmployeeDesignationId); } return(View(employeeProfileViewModel)); }
public EmployeeProfileViewModel SaveProfile(EmployeeProfileViewModel model) { exceptionService.Execute((m) => { var dob = model.DateOfBirthBS.GetDate(); if (dob.IsFutureDate()) { model.AddModelError(x => x.DateOfBirthBS, "DobCanNotBeFutureDate", "Date of birth can not be future date."); } model.DateOfBirth = dob; var appointmentDate = model.AppointmentDateBS.GetDate(); if (appointmentDate.IsFutureDate()) { model.AddModelError(x => x.AppointmentDateBS, "Message.CanNotBeFutureDate", string.Format("{0} can not be future date.", model.GetDisplayName(x => x.AppointmentDateBS))); } model.AppointmentDate = appointmentDate; var dateTo20YrsofServiceDuration = model.DateTo20YrsofServiceDurationBS.GetDate(); if (dateTo20YrsofServiceDuration.IsPastDate()) { model.AddModelError(x => x.DateTo20YrsofServiceDurationBS, "Message.CanNotBeFutureDate", string.Format("{0} can not be past date.", model.GetDisplayName(x => x.DateTo20YrsofServiceDurationBS))); } model.DateTo20YrsofServiceDuration = dateTo20YrsofServiceDuration; var dateTo58YrsOld = model.DateTo58YrsOldBS.GetDate(); if (dateTo58YrsOld.IsPastDate()) { model.AddModelError(x => x.DateTo58YrsOldBS, "Message.CanNotBeFutureDate", string.Format("{0} can not be past date.", model.GetDisplayName(x => x.DateTo58YrsOldBS))); } model.DateTo58YrsOld = dateTo58YrsOld; var citizenshipIssuedDate = model.CitizenshipIssuedDateBS.GetDate(); if (citizenshipIssuedDate.IsFutureDate()) { model.AddModelError(x => x.CitizenshipIssuedDateBS, "Message.CanNotBeFutureDate", string.Format("{0} can not be future date.", model.GetDisplayName(x => x.CitizenshipIssuedDateBS))); } model.CitizenshipIssuedDate = citizenshipIssuedDate == DateTime.MinValue ? (DateTime?)null : citizenshipIssuedDate; var passportIssuedDate = model.PassportIssuedDateBS.GetDate(); if (passportIssuedDate.IsFutureDate()) { model.AddModelError(x => x.PassportIssuedDateBS, "Message.NoFutureDate", string.Format("{0} cannot be future date.", model.GetDisplayName(x => x.PassportIssuedDateBS))); } model.PassportIssuedDate = passportIssuedDate == DateTime.MinValue ? (DateTime?)null : passportIssuedDate; var driverLicenseIssuedDate = model.DriverLicenseIssuedDateBS.GetDate(); if (driverLicenseIssuedDate.IsFutureDate()) { model.AddModelError(x => x.DriverLicenseIssuedDateBS, "Message.NoFutureDate", string.Format("{0} cannot be future date.", model.GetDisplayName(x => x.DriverLicenseIssuedDateBS))); } model.DriverLicenseIssuedDate = driverLicenseIssuedDate == DateTime.MinValue ? (DateTime?)null : driverLicenseIssuedDate; if (!model.Email.IsValidEmail()) { model.AddModelError(x => x.Email, "Message.NoFutureDate", string.Format("{0} not a valid format.", model.GetDisplayName(x => x.DriverLicenseIssuedDateBS))); } if (model.HasError) { return; } if (!model.Validate()) { return; } var entity = employeeRepository.GetById(model.Id); entity.Name = model.Name; entity.FullNameNP = model.FullNameNP; entity.DateOfBirth = model.DateOfBirth; entity.Gender = model.Gender; entity.AppointmentDate = model.AppointmentDate; entity.DateTo20YrsofServiceDuration = model.DateTo20YrsofServiceDuration; entity.DateTo58YrsOld = model.DateTo58YrsOld; entity.FatherName = model.FatherName; entity.MotherName = model.MotherName; entity.GrandFatherName = model.GrandFatherName; entity.SectionId = model.SectionId; entity.DesignationId = model.DesignationId; entity.HomeTelephone = model.HomeTelephone; entity.OfficeTelephone = model.OfficeTelephone; entity.TelExtenstionNumber = model.TelExtenstionNumber; entity.Mobile = model.Mobile; entity.Email = model.Email; entity.PANNumber = model.PANNumber; entity.CitizenshipNumber = model.CitizenshipNumber; //entity.CitizenshipIssuedDistrictId = model.CitizenshipIssuedDistrictId; entity.CitizenshipIssuedDate = model.CitizenshipIssuedDate; entity.PassportNumber = model.PassportNumber; entity.PassportIssuedDate = model.PassportIssuedDate; entity.DriverLicenseNumber = model.DriverLicenseNumber; entity.DriverLicenseIssuedDate = model.DriverLicenseIssuedDate; entity.MaritalStatus = model.MaritalStatus; entity.SupervisorId = model.SupervisorId; entity.EmployeeType = model.EmployeeType; entity.EmployeeStatus = model.EmployeeStatus; employeeRepository.Update(entity); if (model.Id == 0) { model.Message = localizationService.GetLocalizedText("Message.SavedSuccessfully", defaultText: "Saved succeeded."); } else { model.Message = localizationService.GetLocalizedText("Message.UpdatedSuccessfully", defaultText: "Update succeeded."); } }, model); return(model); }