Exemple #1
0
        // GET: Educations/Create
        public IActionResult Create()
        {
            EducationViewModel vm;

            vm = new EducationViewModel(_context);
            return(View(vm));
        }
Exemple #2
0
 public ResponseData AddByEntity(EducationViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Education model = new tb_Education();
             model.EduID      = data.EduID;
             model.EduCode    = data.EduCode;
             model.EduName    = data.EduName;
             model.EduStatus  = (data.Status == "1") ? true : false;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Education.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Exemple #3
0
        private EducationViewModel CreateEducationViewModel(bool useAutoMock = false)
        {
            EducationViewModel viewModel = null;
            var scheduler = new SynchronousTaskScheduler();

            Task.Factory.StartNew(
                () =>
            {
                if (useAutoMock)
                {
                    viewModel = this.fixture.Create <EducationViewModel>();
                }
                else
                {
                    viewModel = new EducationViewModel(
                        this.unitOfWorkMock.Object,
                        this.viewModelBuilderMock.Object,
                        this.viewBuilderMock.Object,
                        this.messageBoxProviderMock.Object,
                        this.educationCacheMock.Object);
                }
            },
                CancellationToken.None,
                TaskCreationOptions.None,
                scheduler);

            return(viewModel);
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, EducationViewModel education)
        {
            if (id != education.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(education.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EducationExists(education.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            education.loadLists(_context);
            return(View(education));
        }
Exemple #5
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));
        }
        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));
        }
Exemple #7
0
        public ActionResult Index(string resumeGUID)
        {
            try
            {
                if (resumeGUID == null || string.IsNullOrWhiteSpace(resumeGUID))
                {
                    resumeGUID = "6257B7B5-C4D0-4D00-ACB4-350A95861B7F";
                }

                var                 viewModel       = new EducationViewModel();
                Repository          _repositoryMain = new Repository(_connectionString);
                EducationRepository _repository     = new EducationRepository(_connectionString);

                Applicant            applicant     = _repositoryMain.GetApplicant(resumeGUID);
                List <EducationItem> educationList = _repository.GetEducationList();

                viewModel.Applicant  = applicant;
                viewModel.Educations = educationList;

                return(View(viewModel));
            }
            catch
            {
                return(View("Error"));
            }
        }
Exemple #8
0
        private void SetEducation(Konsultant newConsultant, EducationViewModel edu)
        {
            Education current = string.IsNullOrEmpty(edu.Id) ?
                                new Education
            {
                Name = edu.Name
            } :
            _eduService.GetById(Guid.Parse(edu.Id));

            if (edu.IsDeleted)
            {
                _eduService.Delete(current);
            }
            else
            {
                newConsultant.Educations.Add(
                    new PersonalEducation
                {
                    Education    = current,
                    EducationId  = current.Id,
                    KonsultantId = newConsultant.Id,
                    StartDate    = edu.StartDate,
                    EndDate      = edu.EndDate,
                    IsRelevant   = edu.IsRelevant
                                   //StartDate = DateTime.ParseExact(edu.StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture),
                                   //EndDate = DateTime.ParseExact(edu.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture)
                });
            }
        }
Exemple #9
0
        public async Task <IActionResult> EditEducation(EducationViewModel model)
        {
            var userId     = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var specialist = await _specialistService.FindAsync(userId);

            if (ModelState.IsValid)
            {
                var education = new Education()
                {
                    Id             = model.Id,
                    StudyPlaceName = model.StudyPlaceName,
                    Specialization = model.Specialization,
                    StartDate      = model.StartDate,
                    EndDate        = model.EndDate,
                    SpecialistId   = specialist.Id
                };
                var result = await _specialistService.UpdateEducation(education);

                if (result != null)
                {
                    TempData["Status"] = "Note has been edited";
                    return(RedirectToAction("EducationsAndExperience"));
                }
            }
            return(View(model));
        }
        public ActionResult Education()
        {
            var education = new EducationViewModel(MenuType.Education, Request.IsAuthenticated, HttpContext.User);

            var educationItem1 = new EducationItemViewModel
            {
                EducationId = 0,
                Picture     = "Education/VIU/viu-logo.png",
                University  = "Vancouver Island University",
                Program     = "Computer Science"
            };

            var educationItem2 = new EducationItemViewModel
            {
                EducationId = 1,
                Picture     = "Education/FESTU/festu-logo.png",
                University  = "Far Eastern Transport State University",
                Program     = "Information Technology"
            };

            education.EducationItems.Add(educationItem1);
            education.EducationItems.Add(educationItem2);

            return(View(education));
        }
        public IActionResult CreateEducation(int personId)
        {
            EducationViewModel model = new EducationViewModel();

            model.PersonId = personId;
            return(View(model));
        }
        public async Task <IActionResult> EditEducation([FromRoute] int?id, [FromBody] EducationViewModel model)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var serviceModel = await this.educationsService.GetByIdAsync(model.Id);

            if (serviceModel == null)
            {
                return(this.NotFound());
            }

            serviceModel.Major       = model.Major;
            serviceModel.Institute   = model.Institute;
            serviceModel.From        = model.From;
            serviceModel.To          = model.To;
            serviceModel.Description = model.Description;

            if (!this.ModelState.IsValid)
            {
                return(NotFound());
            }

            var result = await this.educationsService.UpdateAsync(serviceModel);

            if (!result)
            {
                return(NotFound());
            }

            return(Json(new { success = true }));
        }
Exemple #13
0
        public JsonResult getAllEducationActive()
        {
            EducationViewModel educationModel = new EducationViewModel();

            educationModel.EducationResults = Mapper.Map <IEnumerable <Education> >(_educationService.getAllEducationActive());
            return(Json(educationModel.EducationResults, GlobalConst.Message.text_html, JsonRequestBehavior.AllowGet));
        }
        public static bool EducationYearBeBeforeOrEqual(EducationViewModel instance, string toYear)
        {
            if (string.IsNullOrEmpty(toYear))
            {
                //Will be picked up by required validator
                return(true);
            }

            if (string.IsNullOrEmpty(instance.FromYear))
            {
                return(false);
            }

            int to, from;

            var validTo   = int.TryParse(toYear, out to);
            var validFrom = int.TryParse(instance.FromYear, out from);

            if (validTo && validFrom)
            {
                return(@from <= to);
            }

            return(true);
        }
Exemple #15
0
        public ActionResult DeleteConfirmed(int id)
        {
            EducationViewModel educationViewModel = db.Education.Find(id);

            db.Education.Remove(educationViewModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #16
0
        public void ShouldHaveErrorsOnSaveWhenFromYearGreaterThanToYear()
        {
            var viewModel = new EducationViewModel {
                FromYear = "2000", ToYear = "1990"
            };

            new EducationViewModelSaveValidator().ShouldHaveValidationErrorFor(x => x.ToYear, viewModel);
        }
Exemple #17
0
        public IActionResult UpdateEducation(EducationViewModel model)
        {
            var convertedModel = _mapper.Map <EducationDTO>(model);

            _educationService.UpdateEducation(convertedModel);

            return(RedirectToAction("Education", "Admin"));
        }
Exemple #18
0
        public void ShouldHaveErrorsOnSaveWhenFromYearInTheFuture()
        {
            var viewModel = new EducationViewModel {
                FromYear = Convert.ToString(DateTime.UtcNow.Year + 1)
            };

            new EducationViewModelSaveValidator().ShouldHaveValidationErrorFor(x => x.FromYear, viewModel);
        }
Exemple #19
0
        public void ShouldHaveErrorsOnServerWhenBlank()
        {
            var viewModel = new EducationViewModel();
            var viewModelServerValidator = new EducationViewModelServerValidator();

            viewModelServerValidator.ShouldHaveValidationErrorFor(x => x.NameOfMostRecentSchoolCollege, viewModel);
            viewModelServerValidator.ShouldHaveValidationErrorFor(x => x.FromYear, viewModel);
            viewModelServerValidator.ShouldHaveValidationErrorFor(x => x.ToYear, viewModel);
        }
        public IActionResult EducationPartial()
        {
            var educationModel = new EducationViewModel();

            educationModel.ItemIndex = index;
            index++;

            return(PartialView("~/Views/Shared/EditorTemplates/_EducationPartialView.cshtml", educationModel));
        }
        public void Delete(EducationViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
        public ActionResult Create(EducationViewModel educationViewModel)
        {
            if (ModelState.IsValid)
            {
                _educationManager.IsRegister(educationViewModel);
                return(RedirectToAction("Index", "Education"));
            }

            return(View(educationViewModel));
        }
Exemple #23
0
        public ActionResult EducationDetail(int?id)
        {
            EducationViewModel model = new EducationViewModel();

            if (id.HasValue)
            {
                model = new EducationRepository().GetByID((int)id);
            }
            return(PartialView("_Education", model));
        }
        // 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));
        }
Exemple #25
0
 public ActionResult Edit([Bind(Include = "ID,SchoolName,YearGraduate,NbYearsToGraduate")] EducationViewModel educationViewModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(educationViewModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(educationViewModel));
 }
        private int CalculateLeftSum(EducationViewModel visit)
        {
            int sum     = visit.FinalCost;
            int paidSum = _paymentLogic.Read(new PaymentBindingModel
            {
                EducationId = visit.Id
            }).Select(rec => rec.Sum).Sum();

            return(sum - paidSum);
        }
Exemple #27
0
        public IActionResult CreateEducation(EducationViewModel model)
        {
            ViewBag.ShowNavbar = false;

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

            _educationService.CreateEducation(convertedModel);

            return(RedirectToAction("Education", "Admin"));
        }
Exemple #28
0
        public ActionResult Create([Bind(Include = "ID,SchoolName,YearGraduate,NbYearsToGraduate")] EducationViewModel educationViewModel)
        {
            if (ModelState.IsValid)
            {
                db.Education.Add(educationViewModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(educationViewModel));
        }
Exemple #29
0
        public ActionResult AddEducation(EducationViewModel educationView)
        {
            Education education = Mapper.Map <EducationViewModel, Education>(educationView);

            ApplicationDbContext db = new ApplicationDbContext();

            db.Educations.Add(education);
            db.SaveChanges();

            return(RedirectToAction("EducationMgtView"));
        }
        public IActionResult Create(EducationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(model));
            }

            var id = this.educationService.CreateEducation(model);

            return(this.Redirect("/Educations/Details?id=" + id));
        }
 private void Load(string dataDirectory)
 {
     Introduction = new IntroductionViewModel(new GenericDataAccess<string>(dataDirectory, "Introduction"));
     Identity = new IdentityViewModel(new GenericDataAccess<Identity>(dataDirectory, typeof(Identity).Name));
     Education = new EducationViewModel(new GenericDataAccess<IEnumerable<Education>>(dataDirectory, typeof(Education).Name));
     WorkExperience = new WorkExperienceViewModel(new GenericDataAccess<IEnumerable<WorkExperience>>(dataDirectory, typeof(WorkExperience).Name));
     Skill = new SkillViewModel(new GenericDataAccess<IEnumerable<Skill>>(dataDirectory, typeof(Skill).Name));
 }