public ActionResult AddUserEducation(UserEducationViewModel viewmodel)
        {
            UserEducation usereducation = new UserEducation()
            {
                LinkedInUserId = User.Identity.GetUserId(),
                Degree         = viewmodel.Myeducation.Degree,
                Activities     = viewmodel.Myeducation.Activities,
                Descriptions   = viewmodel.Myeducation.Descriptions,
                EndDate        = viewmodel.Myeducation.EndDate,
                Fieldofstudy   = viewmodel.Myeducation.Fieldofstudy,
                Grade          = viewmodel.Myeducation.Grade,
                StartingDate   = viewmodel.Myeducation.StartingDate,
                University     = viewmodel.Myeducation.University
            };



            if (ModelState.IsValid)
            {
                mydatabase.UserEducationManager.Add(usereducation);
            }
            string userid = User.Identity.GetUserId();

            AppUserViewModel myviewmodel = new AppUserViewModel()
            {
                EducationList = mydatabase.UserEducationManager.GetAllBind().Where(i => i.LinkedInUserId == userid).ToList()
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_PartialProfileEducationwithedit", myviewmodel));
            }
            return(PartialView("_PartialProfileEducationwithedit", myviewmodel));
        }
        // GET: userEducation/Create
        public ActionResult AddUserEducation()
        {
            UserEducationViewModel myview = new UserEducationViewModel();

            myview.Faculties    = mydatabase.FacultyUserManager.GetAllBind();
            myview.Universities = mydatabase.UniversityUserManager.GetAllBind();

            return(View(myview));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(string userId)
        {
            if (userId == null)
            {
                _loggerService.LogError("User id is null");

                return(NotFound());
            }
            var user = await _userService.GetUserAsync(userId);

            var currentUserId = _userManager.GetUserId(User);
            var currentUser   = await _userService.GetUserAsync(currentUserId);

            if (!(userId == currentUserId || await _userManagerService.IsInRoleAsync(currentUser, Roles.Admin)))
            {
                _loggerService.LogError($"User (id: {currentUserId}) hasn't access to edit profile (id: {userId})");
                return(StatusCode(StatusCodes.Status403Forbidden));
            }

            if (user != null)
            {
                var genders            = _mapper.Map <IEnumerable <GenderDTO>, IEnumerable <GenderViewModel> >(await _userPersonalDataService.GetAllGendersAsync());
                var placeOfStudyUnique = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _userPersonalDataService.GetAllEducationsGroupByPlaceAsync());
                var specialityUnique   = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _userPersonalDataService.GetAllEducationsGroupBySpecialityAsync());
                var placeOfWorkUnique  = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _userPersonalDataService.GetAllWorkGroupByPlaceAsync());
                var positionUnique     = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _userPersonalDataService.GetAllWorkGroupByPositionAsync());
                var upuDegrees         = _mapper.Map <IEnumerable <UpuDegreeDTO>, IEnumerable <UpuDegreeViewModel> >(await _userPersonalDataService.GetAllUpuDegreesAsync());

                var educView = new UserEducationViewModel {
                    PlaceOfStudyID = user.UserProfile.EducationId, SpecialityID = user.UserProfile.EducationId, PlaceOfStudyList = placeOfStudyUnique, SpecialityList = specialityUnique
                };
                var workView = new UserWorkViewModel {
                    PlaceOfWorkID = user.UserProfile.WorkId, PositionID = user.UserProfile.WorkId, PlaceOfWorkList = placeOfWorkUnique, PositionList = positionUnique
                };
                var model = new EditUserViewModel()
                {
                    User          = _mapper.Map <UserDTO, UserViewModel>(user),
                    Nationalities = _mapper.Map <IEnumerable <NationalityDTO>, IEnumerable <NationalityViewModel> >(await _userPersonalDataService.GetAllNationalityAsync()),
                    Religions     = _mapper.Map <IEnumerable <ReligionDTO>, IEnumerable <ReligionViewModel> >(await _userPersonalDataService.GetAllReligionsAsync()),
                    EducationView = educView,
                    WorkView      = workView,
                    Degrees       = _mapper.Map <IEnumerable <DegreeDTO>, IEnumerable <DegreeViewModel> >(await _userPersonalDataService.GetAllDegreesAsync()),
                    Genders       = genders,
                    UpuDegrees    = upuDegrees,
                };

                return(Ok(model));
            }
            _loggerService.LogError($"User not found. UserId:{userId}");
            return(NotFound());
        }
Ejemplo n.º 4
0
        public JsonResult SaveEducation(UserEducationViewModel data, HttpPostedFileBase fileUpload)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UeID != 0)
            {
                result = new EmployeeRepository().UpdateEducationByEntity(data);
            }
            else
            {
                result = new EmployeeRepository().AddEducationByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(string userId)
        {
            if (userId == null)
            {
                _loggerService.LogError("User id is null");

                return(NotFound());
            }
            var user = await _userService.GetUserAsync(userId);

            if (user != null)
            {
                var genders            = _mapper.Map <IEnumerable <GenderDTO>, IEnumerable <GenderViewModel> >(await _genderService.GetAllAsync());
                var placeOfStudyUnique = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _educationService.GetAllGroupByPlaceAsync());
                var specialityUnique   = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _educationService.GetAllGroupBySpecialityAsync());
                var placeOfWorkUnique  = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _workService.GetAllGroupByPlaceAsync());
                var positionUnique     = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _workService.GetAllGroupByPositionAsync());

                var educView = new UserEducationViewModel {
                    PlaceOfStudyID = user.UserProfile.EducationId, SpecialityID = user.UserProfile.EducationId, PlaceOfStudyList = placeOfStudyUnique, SpecialityList = specialityUnique
                };
                var workView = new UserWorkViewModel {
                    PlaceOfWorkID = user.UserProfile.WorkId, PositionID = user.UserProfile.WorkId, PlaceOfWorkList = placeOfWorkUnique, PositionList = positionUnique
                };
                var model = new EditUserViewModel()
                {
                    User          = _mapper.Map <UserDTO, UserViewModel>(user),
                    Nationalities = _mapper.Map <IEnumerable <NationalityDTO>, IEnumerable <NationalityViewModel> >(await _nationalityService.GetAllAsync()),
                    Religions     = _mapper.Map <IEnumerable <ReligionDTO>, IEnumerable <ReligionViewModel> >(await _religionService.GetAllAsync()),
                    EducationView = educView,
                    WorkView      = workView,
                    Degrees       = _mapper.Map <IEnumerable <DegreeDTO>, IEnumerable <DegreeViewModel> >(await _degreeService.GetAllAsync()),
                    Genders       = genders,
                };

                return(Ok(model));
            }
            _loggerService.LogError($"User not found. UserId:{userId}");
            return(NotFound());
        }