public static Education DTOToEducation(EducationDTO educationDTO)
        {
            DateTime?inputStartDate = educationDTO.StartDate;

            if (educationDTO.StartDate.HasValue)
            {
                inputStartDate = educationDTO.StartDate.GetValueOrDefault();
            }
            DateTime?inputEndDate = educationDTO.EndDate;

            if (educationDTO.EndDate.HasValue)
            {
                inputEndDate = educationDTO.EndDate.GetValueOrDefault();
            }
            return(new Education
            {
                ResumeId = educationDTO.ResumeId,
                Order = educationDTO.Order,
                SchoolName = educationDTO.SchoolName,
                StartDate = inputStartDate,
                EndDate = inputEndDate,
                Major = educationDTO.Major,
                Resume = null
            });
        }
示例#2
0
        public ActionResult Create(EducationViewModel model)
        {
            if (model != null)
            {
                var fileName  = Path.GetFileNameWithoutExtension(model.ImageFile.FileName);
                var extension = Path.GetExtension(model.ImageFile.FileName);
                fileName           = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                model.DiplomaPhoto = "~/Areas/production/images/" + fileName;
                fileName           = Path.Combine(Server.MapPath("~/Areas/production/images/"), fileName);
                model.ImageFile.SaveAs(fileName);

                var educationDTO = new EducationDTO
                {
                    Name         = model.Name.Trim(),
                    GPA          = model.GPA,
                    DiplomaPhoto = model.DiplomaPhoto.Trim(),
                    CityId       = model.CityId,
                    UserId       = model.UserId
                };

                educationService.Create(educationDTO);

                ModelState.Clear();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#3
0
        public ActionResult AddSubject(EducationViewModel educationVM)
        {
            if (ModelState.IsValid)
            {
                Validate validate = new Validate();
                if (!(validate.ValidationSubjectRes(educationVM.SubjectResult)))
                {
                    ViewBag.message = "Введіть оцінку ще раз";
                    return(View("Report"));
                }

                int idSubject = subjectService.Get().Where(s => s.Name == educationVM.SubjectName).FirstOrDefault().Id;
                educationVM.IdSubject = idSubject;
                EducationDTO educationDTO1 = educationService.Get().Where(s => s.IdStudent == educationVM.IdStudent).Where(s => s.IdSubject == educationVM.IdSubject).FirstOrDefault();

                if (educationDTO1 != null)
                {
                    ViewBag.message = "Студент вже має такий предмет";
                    return(View("Report"));
                }

                var          mapper       = new MapperConfiguration(cfg => cfg.CreateMap <EducationViewModel, EducationDTO>()).CreateMapper();
                EducationDTO educationDTO = mapper.Map <EducationViewModel, EducationDTO>(educationVM);

                educationService.AddSubject(educationDTO);
                StudentDTO studentDTO = studentService.GetStudent(educationDTO.IdStudent);
                studentDTO.StudentAvg = studentService.GetStudentAvg(studentDTO.Id);
                SubjectDTO subjectDTO = subjectService.GetSubject(educationDTO.IdSubject);
                subjectDTO.SubjectAvg = subjectService.GetSubjectAvg(subjectDTO.Id);

                ViewBag.message = "Предмет додано до даних студента";
                return(View("Report"));
            }
            return(View(educationVM));
        }
示例#4
0
        public async Task <Result <SkillsDTO> > GetUserSkills(string userId)
        {
            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(Result <SkillsDTO> .CreateFailed(
                           HttpStatusCode.NotFound, "User not found"));
            }

            var expiriences = await _context.Experiences.Where(x => x.User == user).ToListAsync();

            var educations = await _context.Educations.Where(x => x.User == user).ToListAsync();

            var personalSkills = await _context.PersonalSkills.Where(x => x.User == user).ToListAsync();

            var a = Result <SkillsDTO> .CreateSuccessful(
                new SkillsDTO(
                    ExperienceDTO.ToExperienceDTOList(expiriences),
                    EducationDTO.ToEducationDTOList(educations),
                    PersonalSkillDTO.ToPersonalSkillDTOList(personalSkills)
                    ));

            return(a);
        }
        public async Task CreateAsync(EducationDTO educationDTO)
        {
            // if no Degree is provided
            if (educationDTO.Degree == null)
            {
                throw new ArgumentNullException(nameof(educationDTO.Degree));
            }

            var adminRoleId = this.roles.AllAsNoTracking().FirstOrDefault(x => x.Name == GlobalConstants.AdministratorRoleName).Id;
            var user        = this.users.All().FirstOrDefault(x => x.Roles.Any(x => x.RoleId == adminRoleId));

            var education = new Education
            {
                Degree        = educationDTO.Degree.Trim(),
                Speciality    = educationDTO.Speciality.Trim(),
                Institution   = educationDTO.Institution.Trim(),
                StartYear     = int.Parse(educationDTO.StartYear.Trim()),
                EndYear       = int.Parse(educationDTO.EndYear.Trim()),
                IconClassName = educationDTO.IconClassName.Trim(),
                Details       = educationDTO.Details.Trim(),
                UserId        = user.Id,
            };

            await this.educationsRepository.AddAsync(education);

            await this.educationsRepository.SaveChangesAsync();
        }
示例#6
0
        /// <summary>
        /// 添加用户教育经历
        /// </summary>
        /// <param name="education">教育经历</param>
        public List <EducationDTO> AddEducation(EducationDTO education)
        {
            var userid = HttpContext.Current.User.Identity.Name;

            using (var db = new AspodesDB())
            {
                var userInfo = db.Users.FirstOrDefault(c => c.UserId == userid);
                if (userInfo != null)
                {
                    education.EducationId = Guid.NewGuid().ToString("D");
                    List <EducationDTO> educationList = new List <EducationDTO>();
                    if (!string.IsNullOrEmpty(userInfo.Person.EducationHistor))
                    {
                        educationList = JsonConvert.DeserializeObject <List <EducationDTO> >(userInfo.Person.EducationHistor);
                    }
                    educationList.Add(education);

                    userInfo.Person.EducationHistor = JsonConvert.SerializeObject(educationList);

                    db.SaveChanges();
                    return(educationList);
                }
                else
                {
                    throw new NotFoundException("找不到用户!");
                }
            }
        }
        public IHttpActionResult PutEducation(int id, EducationDTO education)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != education.EducationID)
            {
                return(BadRequest());
            }

            try
            {
                db.Update(education);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EducationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#8
0
        public EducationDTO newEducation(EducationDTO Education)
        {
            var adedEducation = MapperFactory.CurrentMapper.Map <Education>(Education);

            adedEducation = uow.GetRepository <Education>().Add(adedEducation);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EducationDTO>(adedEducation));
        }
示例#9
0
        public void CreateEducation(EducationDTO model)
        {
            var convertedModel = _mapper.Map <Education>(model);

            convertedModel.Added = DateTime.Now;

            _genericRepository.Create(convertedModel);
        }
示例#10
0
        public EducationDTO Create(EducationDTO modelDTO)
        {
            if (modelDTO != null)
            {
                return(EducationAssembler.ToDTO(EducationsRepo.Create(EducationAssembler.ToEntity(modelDTO))));
            }

            return(null);
        }
示例#11
0
        public EducationDTO updateEducation(EducationDTO Education)
        {
            var selectedEducation = uow.GetRepository <Education>().Get(z => z.Id == Education.EducationsTypeID);

            selectedEducation = MapperFactory.CurrentMapper.Map(Education, selectedEducation);
            uow.GetRepository <Education>().Update(selectedEducation);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EducationDTO>(selectedEducation));
        }
示例#12
0
        // Student/EditEducation
        public ActionResult EditEducation(int idEducation)
        {
            EducationDTO educationDTO = educationService.GetEducation(idEducation);

            IMapper            mapper      = new MapperConfiguration(cfg => cfg.CreateMap <EducationDTO, EducationViewModel>()).CreateMapper();
            EducationViewModel educationVM = mapper.Map <EducationDTO, EducationViewModel>(educationDTO);

            educationVM.SubjectName = educationService.SetSubjectName(educationVM.Id);
            return(View("EditEducation", educationVM));
        }
示例#13
0
 public IActionResult AddEducation(EducationDTO educationDTO)
 {
     if (educationDTO.EducationsTypeID == 0)
     {
         var emp = employeeservice.getEmployeeUser(CurrentUser.Id);
         educationDTO.EducationsTypeID = emp.Id;
     }
     service.newEducation(educationDTO);
     return(RedirectToAction("Index", "Home"));
 }
        public HttpResponseMessage Get(int Id)
        {
            EducationDTO selectedTitle = service.getEducation(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
示例#15
0
        public void EditEducation(EducationDTO educationDTO)
        {
            IMapper   mapper    = new MapperConfiguration(cfg => cfg.CreateMap <EducationDTO, Education>()).CreateMapper();
            Education education = Database.EducationsRepository.FindById(educationDTO.Id);

            education = mapper.Map <EducationDTO, Education>(educationDTO);

            Database.EducationsRepository.Update(education);
            Database.SaveChanges();
        }
示例#16
0
        public void UpdateEducation(EducationDTO model)
        {
            var added = _genericRepository.GetAdded(model.Id);

            var convertedModel = _mapper.Map <Education>(model);

            convertedModel.Updated = DateTime.Now;
            convertedModel.Added   = added;

            _genericRepository.Update(convertedModel);
        }
        public IHttpActionResult GetEducation(int id)
        {
            EducationDTO education = db.Get(id);

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

            return(Ok(education));
        }
        public IHttpActionResult PostEducation(EducationDTO education)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Create(education);

            return(CreatedAtRoute("DefaultApi", new { id = education.EducationID }, education));
        }
        public Education EditEducation(int educationId, EducationDTO educationDTO)
        {
            var editEducation = _context.Education.Find(educationId);

            editEducation.EducationName = educationDTO.EducationName;
            editEducation.Degree        = educationDTO.Degree;
            editEducation.Speciality    = educationDTO.Speciality;
            editEducation.Graduated     = educationDTO.Graduated;

            return(editEducation);
        }
        public async Task <Education> AddEducation(int userId, EducationDTO educationDTO)
        {
            var education = new Education(educationDTO.EducationName, educationDTO.Degree,
                                          educationDTO.Speciality, educationDTO.Graduated, userId);

            await _context.Education.AddAsync(education);

            await _context.SaveChangesAsync();

            return(education);
        }
示例#21
0
        public async Task <IActionResult> AddEducation(int userId, [FromBody] EducationDTO educationForAddd)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            await _repo.AddEducation(userId, educationForAddd);

            return(Ok());
        }
示例#22
0
 public HttpResponseMessage Post(EducationDTO education)
 {
     try
     {
         return(ResponseWrapper.SuccessResponse(repository.AddEducation(education)));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
示例#23
0
        public EducationDTO Update(EducationDTO modelDTO)
        {
            EducationDTO returnEducation = null;

            if (modelDTO != null && modelDTO.EducationID > 0)
            {
                EducationsRepo.Update(0, EducationAssembler.ToEntity(modelDTO));
                returnEducation = modelDTO;
            }

            return(returnEducation);
        }
示例#24
0
        public async Task <IActionResult> EditEducation(int userId, int id,
                                                        [FromBody] EducationDTO educationForEdit)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            _repo.EditEducation(id, educationForEdit);
            await _repo.SaveAll();

            return(Ok());
        }
示例#25
0
文件: Education.cs 项目: Sakis94/Ted
 public void Update(EducationDTO education)
 {
     Degree      = education.Degree;
     Field       = education.Field;
     Grade       = education.Grade;
     StartDate   = education.StartDate;
     EndDate     = education.EndDate;
     Link        = education.Link;
     StillThere  = education.StillThere;
     Title       = education.Title;
     Description = education.Description;
     IsPublic    = education.IsPublic;
 }
        public HttpResponseMessage Put(EducationDTO EducationDTO)
        {
            EducationDTO dto = service.updateEducation(EducationDTO);

            if (dto != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
            }
        }
示例#27
0
 public EducationDTO newEducation(EducationDTO Education)
 {
     if (!uow.GetRepository <Education>().GetAll().Any(z => z.Id == Education.Id))
     {
         var adedEducation = MapperFactory.CurrentMapper.Map <Education>(Education);
         adedEducation = uow.GetRepository <Education>().Add(adedEducation);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <EducationDTO>(adedEducation));
     }
     else
     {
         return(null);
     }
 }
        public async Task <ActionResult <EducationDTO> > PostEducation(EducationDTO educationDTO)
        {
            Education sanitizedEducation = DTOToEducation(educationDTO);

            if (!await ResumeAccessAuthorized(sanitizedEducation.ResumeId))
            {
                return(GenerateResumeNotFoundError(sanitizedEducation.ResumeId));
            }

            _context.Education.Add(sanitizedEducation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("PostEducation", new { resumeId = sanitizedEducation.ResumeId, order = sanitizedEducation.Order }, educationDTO));
        }
示例#29
0
        public EducationDTO Get(int id)
        {
            EducationDTO oEducationDTO = null;

            if (id > 0)
            {
                Education oEducation = EducationsRepo.Get(id);
                if (oEducation != null)
                {
                    oEducationDTO = EducationAssembler.ToDTO(oEducation);
                }
            }

            return(oEducationDTO);
        }
        public HttpResponseMessage Post(EducationDTO EducationDTO)
        {
            EducationDTO dto = service.newEducation(EducationDTO);

            if (dto != null)
            {
                HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto);
                message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id);
                return(message);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title));
            }
        }