public ActionResult Create(CreateMenteeView model) { //if (ModelState.IsValid) //{ //Mentee mentee = new Mentee //{ // MenteeName = model.MenteeName, // Age = model.Age, // LevelId = model.Position //}; // Настройка конфигурации AutoMapper var config = new MapperConfiguration(cfg => cfg.CreateMap <CreateMenteeView, Mentee>(). ForMember("LevelId", opt => opt.MapFrom(c => c.Position))); var mapper = new Mapper(config); // Выполняем сопоставление //var mentees = unitOfWork.Mentee.GetAll(); Mentee mentee = mapper.Map <CreateMenteeView, Mentee>(model); //unitOfWork.Mentee.Create(mentee); // } unitOfWork.Mentee.Create(mentee); CreateMenteeView mView = new CreateMenteeView(); mView = model.NewLevel(); //mentee.MenteeId= unitOfWork.Mentee.GetAll().ToList().Last().MenteeId; //++mentee.MenteeId; //if (mentee.MenteeId > 0) //{ unitOfWork.Save(); return(RedirectToAction("Mentee")); // } return(View(mView)); }
public IActionResult Create() { CreateMenteeView create = new CreateMenteeView(); return(View(create.NewLevel())); }