Exemple #1
0
        public IActionResult AddEducation(AddEducationViewModel model)
        {
            if (ModelState.IsValid)
            {
                EmployeeEducation newEducation = new EmployeeEducation
                {
                    EmployeeId    = model.EmployeeId,
                    Department    = model.Department,
                    DegreeId      = model.DegreeId,
                    Degree        = model.Degree,
                    Institution   = model.Institution,
                    StillStudying = model.StillStudying,

                    Notes          = model.Notes,
                    Thesis         = model.Thesis,
                    EntranceDate   = model.EntranceDate,
                    GraduationDate = model.GraduationDate
                };
                _employeeRepository.AddEmpEducation(newEducation);

                var successMessage = "Education InfoCreated Successfully. Name: " + newEducation.EmployeeId;
                TempData["successAlert"] = successMessage;
                // return RedirectToAction( successMessage, "");
                return(PartialView("_PartialMessage"));
            }
            return(View());
        }
        public IHttpActionResult Add(AddEducationViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var experience = AutoMapper.Mapper.Map<Education>(model);
                var organization = this.GetOrganization(model);

                experience.Organization = organization;
                experience.OrganizationId = organization.Id;

                //experience.JosSeekerProfile =
                //    this.data.JobSeekerProfiles.All().FirstOrDefault(x => x.UserId == this.CurrentUser.Id);

                this.data.Eductaion.Add(experience);
                this.data.SaveChanges();

                model.Id = experience.Id;

                this.data.SaveChanges();

                return this.Ok(model);
            }

            return this.BadRequest();
        }
Exemple #3
0
 protected void UpdateEducationFromView(AddEducationViewModel model, UserEducation original)
 {
     original.Country          = model.Country;
     original.InstituteName    = model.InstituteName;
     original.Title            = model.Title;
     original.YearOfGraduation = model.YearOfGraduation;
 }
Exemple #4
0
        public ActionResult AddPersonEducation(AddEducationViewModel education)
        {
            try
            {
                var newEducation = new PersonEducation
                {
                    PersonId         = _appContext.LoginId,
                    InstituteName    = education.InstituteName,
                    Country          = education.Country,
                    Title            = education.Title,
                    Degree           = education.Degree,
                    YearOfGraduation = education.YearOfGraduation,
                    CreatedOn        = DateTime.Now,
                    CreatedBy        = _appContext.LoginId,
                    UpdatedBy        = _appContext.LoginId,
                    UpdatedOn        = DateTime.Now,
                };

                _personEducationRepository.Add(newEducation);
                return(new JsonCamelCaseResult(new { Success = true, newEducation.Id }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(new JsonCamelCaseResult(new { Success = false, Message = "Error while adding new language" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #5
0
        public ActionResult EditPersonEducation(AddEducationViewModel education)
        {
            var existingEducation = _personEducationRepository.GetById(education.Id);

            if (ModelState.IsValid && existingEducation != null)
            {
                if (existingEducation.PersonId != _appContext.LoginId)
                {
                    return(new JsonCamelCaseResult(new { Success = false, Message = "You are not allowed to edit this education record" }, JsonRequestBehavior.AllowGet));
                }

                existingEducation.Country          = education.Country;
                existingEducation.Degree           = education.Degree;
                existingEducation.InstituteName    = education.InstituteName;
                existingEducation.Title            = education.Title;
                existingEducation.YearOfGraduation = education.YearOfGraduation;
                existingEducation.UpdatedOn        = DateTime.Now;
                existingEducation.UpdatedBy        = _appContext.LoginId;

                _personEducationRepository.Update(existingEducation);

                return(new JsonCamelCaseResult(new { Success = true }, JsonRequestBehavior.AllowGet));
            }
            return(new JsonCamelCaseResult(new { Success = false, Message = "There was an error in the recieved education data" }, JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> DeleteEducation([FromBody] AddEducationViewModel model)
        {
            try
            {
                var userId = _userAppContext.CurrentUserId;
                var user   = await _userRepository.GetByIdAsync(userId);

                if (user != null)
                {
                    var findEducationItem = user.Education.SingleOrDefault(x => x.Id == model.Id);
                    if (findEducationItem != null)
                    {
                        findEducationItem.IsDeleted = true;
                        user.Education[user.Education.FindIndex(x => x.Id == model.Id)] = findEducationItem;
                        await _userRepository.Update(user);

                        return(Json(new { Success = true }));
                    }
                    else
                    {
                        return(Json(new { Success = false, Message = "Can't find the education!" }));
                    }
                }
                else
                {
                    return(Json(new { Success = false, Message = "Can't find the user!" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { Message = "error" }));
            }
        }
        public async Task <bool> UpdateEducation(AddEducationViewModel model)
        {
            try
            {
                var  userId      = _userAppContext.CurrentUserId;
                User userProfile = await _userRepository.GetByIdAsync(userId);

                if (userProfile == null)
                {
                    return(false);
                }
                var orginalEducation = userProfile.Education.SingleOrDefault(x => x.Id == model.Id);
                if (orginalEducation == null)
                {
                    return(false);
                }
                UpdateEducationFromView(model, orginalEducation);
                await _userRepository.Update(userProfile);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public async Task <bool> AddNewEducation(AddEducationViewModel model)
        {
            try
            {
                var  userId      = _userAppContext.CurrentUserId;
                User userProfile = await _userRepository.GetByIdAsync(userId);

                if (userProfile == null)
                {
                    return(false);
                }

                var newEducation = new UserEducation
                {
                    Id        = ObjectId.GenerateNewId().ToString(),
                    IsDeleted = false,
                    UserId    = userId
                };
                UpdateEducationFromView(model, newEducation);
                userProfile.Education.Add(newEducation);
                await _userRepository.Update(userProfile);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult AddEducation(AddEducationViewModel viewModel)
        {
            ModelState.Clear();
            var validation = TryValidateModel(viewModel);
            var errors     = (from modelstate in ModelState.Values from error in modelstate.Errors select error.ErrorMessage).ToList();

            if (!validation)
            {
                return(Json(errors.ToArray()));
            }

            _studentFacade.InsertPrevEducation(viewModel.Education, User.Identity.Name);
            errors.Add("Finish");
            return(Json(errors.ToArray()));
        }
        public async Task <IActionResult> UpdateEducation([FromBody] AddEducationViewModel model)
        {
            try
            {
                var result = await _profileService.UpdateEducation(model);

                if (result == false)
                {
                    return(Json(new { Success = false, data = "can not update the education." }));
                }
                return(Json(new { Success = true, data = "update the education successful." }));
            }
            catch (Exception e)
            {
                return(Json(new { Success = false, data = "error" }));
            }
        }
        private Organization GetOrganization(AddEducationViewModel model)
        {
            var organization = this.data.Organizations.All().Where(x => !x.IsDeleted)
                .FirstOrDefault(x => x.Name == model.OrganizationName);

            if (organization == null)
            {
                organization = new Organization()
                {
                    Name = model.OrganizationName,
                    Industry = (Industry)model.Industry
                };
            }

            this.data.Organizations.Add(organization);
            this.data.SaveChanges();

            return organization;
        }
 public async Task <IActionResult> DeleteEducation([FromBody] AddEducationViewModel model)
 {
     //Your code here;
     throw new NotImplementedException();
 }
 public IActionResult AddEducation([FromBody] AddEducationViewModel model)
 {
     //Your code here;
     throw new NotImplementedException();
 }
Exemple #14
0
 public Task <bool> AddNewEducation(AddEducationViewModel education)
 {
     throw new NotImplementedException();
 }