public ActionResult Create(EmployerFormViewModel employerForm, System.Web.HttpPostedFileBase upload) { if (ModelState.IsValid) { var employer = Mapper.Map <EmployerFormViewModel, Employer>(employerForm); employer.CreatedBy = "mdemirci"; //User.Identity.Name employer.CreateDate = DateTime.Now; employer.UpdatedBy = "mdemirci"; employer.UpdateDate = employer.CreateDate; if (upload != null) { string dosyaYolu = Path.GetFileName(upload.FileName); var yuklemeYeri = Path.Combine(Server.MapPath("~/Uploads/Employer"), dosyaYolu); upload.SaveAs(yuklemeYeri); employer.Logo = upload.FileName; } employerService.CreateEmployer(employer); employerService.SaveEmployer(); return(RedirectToAction("Index")); } ViewBag.SectorId = new SelectList(sectorService.GetSectors(), "SectorId", "SectorName"); ViewBag.CityId = new SelectList(cityService.GetCities(), "CityId", "CityName"); return(View(employerForm)); }
public EmployerViewModel SaveEmployer(EmployerViewModel viewModel) { var employer = Mapper.Map <EmployerViewModel, Employer>(viewModel); employer = _employerService.SaveEmployer(employer); return(Mapper.Map <Employer, EmployerViewModel>(employer)); }