// GET: Interships/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Intership intership = db.Interships.Include(t => t.IntershipFullDescription).FirstOrDefault(t => t.ID == id); if (intership == null) { return(HttpNotFound()); } ViewBag.Stations = db.DictStateInterships.ToList(); var model = new Intership_MVC_Model { ID = intership.ID, IntershipFullDescription = intership.IntershipFullDescription, DictStateIntership_ID = intership.DictStateIntership.ID, IntershipShortDescription = intership.IntershipShortDescription, IntershipName = intership.IntershipName, DateCreate = intership.DateCreate, DateEdit = intership.DateEdit, ID_Employer = intership.ID_Employer, ImproverPosition = intership.ImproverPosition }; return(View(model)); }
public ActionResult Create(Intership_MVC_Model model) { if (ModelState.IsValid) { var intership = new Intership { DictStateIntership = db.DictStateInterships.FirstOrDefault(t => t.ID == model.ID), DateCreate = DateTime.Now, DateEdit = DateTime.Now, ID_Employer = 1, //TODO исправить после привязки ImproverPosition = model.ImproverPosition, IntershipFullDescription = model.IntershipFullDescription, IntershipName = model.IntershipName, IntershipShortDescription = model.IntershipShortDescription }; db.Interships.Add(intership); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }