// // GET: /Default1/Create public ActionResult Create() { var request = new Request(); ViewBag.State_id = new SelectList(db.States, "Id", "Name", 1); ViewBag.Contragent_id = new SelectList(db.Contragents, "Id", "FIO"); request.Date = DateTime.Now; return View(request); }
public ActionResult Create(Request request) { if (ModelState.IsValid) { db.Requests.AddObject(request); db.SaveChanges(); return RedirectToAction("Edit", new { @id = request.Id }); } ViewBag.State_id = new SelectList(db.States, "Id", "Name", request.State_id); ViewBag.Contragent_id = new SelectList(db.Contragents, "Id", "FIO", request.Contragent_id); return View(request); }
public ActionResult Edit(Request request) { if (ModelState.IsValid) { db.Requests.Attach(request); db.ObjectStateManager.ChangeObjectState(request, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.State_id = new SelectList(db.States, "Id", "Name", request.State_id); ViewBag.Contragent_id = new SelectList(db.Contragents, "Id", "FIO", request.Contragent_id); return View(request); }
/// <summary> /// Deprecated Method for adding a new object to the Requests EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRequests(Request request) { base.AddObject("Requests", request); }
/// <summary> /// Create a new Request object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="contragent_id">Initial value of the Contragent_id property.</param> /// <param name="state_id">Initial value of the State_id property.</param> /// <param name="updated_at">Initial value of the Updated_at property.</param> public static Request CreateRequest(global::System.Int32 id, global::System.DateTime date, global::System.Int32 contragent_id, global::System.Int32 state_id, global::System.DateTime updated_at) { Request request = new Request(); request.Id = id; request.Date = date; request.Contragent_id = contragent_id; request.State_id = state_id; request.Updated_at = updated_at; return request; }