예제 #1
0
        public IActionResult CreateOrUpdate(CandidateCreateModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Foto != null)
                {
                    var uniqueFileName = GetUniqueFileName(model.Foto.FileName);
                    var uploads        = Path.Combine(appEnvironment.WebRootPath, "uploads");
                    var filePath       = Path.Combine(uploads, uniqueFileName);
                    model.Foto.CopyTo(new FileStream(filePath, FileMode.Create));
                    model.FotoURL = filePath;
                }

                var entity = mapper.Map <Candidate>(model);
                foreach (var item in model.SkillsId)
                {
                    var skill = skillManager.Get(item);
                    (entity.Skills as List <Skill>).Add(skill);
                }
                entity.Creator = userManager.GetByLogin(User.Identity.Name);
                if (entity.Id == 0)
                {
                    candidateManager.Create(entity);
                }
                else
                {
                    candidateManager.Update(entity);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
        public IActionResult Create(VacancyCreateModel createModel)
        {
            var model = mapper.Map <Vacancy>(createModel);

            foreach (var item in createModel.SkillsId)
            {
                var skill = skillManager.Get(item);
                (model.Skills as List <Skill>).Add(skill);
            }
            model.Creator = userManager.GetByLogin(User.Identity.Name);
            vacancyManager.CreateProc(model);
            return(RedirectToAction("Index", "Vacancy"));
        }