public ActionResult Create(FormCollection collection) { try { BrokerageFirm model = new BrokerageFirm(); TryUpdateModel(model, collection); model.CreatedAt = DateTime.Now; model.CreatedBy = "SYSTEM"; if (!ModelState.IsValid) { FlashError("数据验证未通过,请检查是否存在为空的必填项"); return(View(model)); } model.CreatedAt = DateTime.Now; model.CreatedBy = "SYSTEM"; var r = _service.Create(model); if (r.HasError) { FlashMessage(r); return(View(model)); } return(RedirectToAction("Index")); } catch (Exception e) { return(View()); } }
public IHttpActionResult Create(BrokerageFirm brokerageFirm) { brokerageFirm.Id = db.BrokerageFirms.Count + 1; db.BrokerageFirms.Add(brokerageFirm); UpdateDb(); return Ok(brokerageFirm); }
public ActionResult Edit(int id, FormCollection collection) { var model = new BrokerageFirm(); TryUpdateModel(model, collection); if (!ModelState.IsValid) { FlashError("数据验证未通过,请检查是否存在为空的必填项"); return(View(model)); } model.UpdatedBy = "SYSTEM"; model.UpdatedAt = DateTime.Now; var r = _service.Update(model); if (r.HasError) { FlashMessage(r); return(View(model)); } return(RedirectToAction("Index")); }