public ActionResult Edit(string id, FormCollection fc) { var bll = new TeamBll(); var model = bll.GetTeamById(id); model.Userid = fc["Userid"]; model.Company = fc["optCompany"].ToString(); model.Lineid = fc["optLine"].ToString(); model.Status = Int32.Parse(fc["optStatus"].ToString()); try { bll.EditTeam(model); } catch (ValidException ex) { this.ModelState.AddModelError(ex.Name, ex.Message); List <SelectListItem> company = bll.GetCompany(); List <SelectListItem> line = bll.GetLine(); List <SelectListItem> Status = new MemberBll().GetDict(3); foreach (SelectListItem r in company) { ViewBag.company += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } foreach (SelectListItem r in line) { ViewBag.line += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } foreach (SelectListItem r in Status) { ViewBag.Status += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } return(View(model)); } return(this.RefreshParent()); }
public ActionResult Edit(string id) { var bll = new TeamBll(); var model = bll.GetTeamById(id); List <SelectListItem> company = bll.GetCompany(); List <SelectListItem> line = bll.GetLine(); List <SelectListItem> Status = new MemberBll().GetDict(3); foreach (SelectListItem r in company) { if (model.Company != null) { if (model.Company.ToString() == r.Value) { ViewBag.company += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>"; } else { ViewBag.company += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } } else { if (r.Value == "3cd53ba4-5c76-11e6-a2c5-6c92bf314f0b") { ViewBag.company += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>"; } else { ViewBag.company += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } } } foreach (SelectListItem r in line) { if (model.Lineid.ToString() == r.Value) { ViewBag.line += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>"; } else { ViewBag.line += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } } foreach (SelectListItem r in Status) { if (model.Status.ToString() == r.Value) { ViewBag.Status += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>"; } else { ViewBag.Status += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>"; } } return(View(model)); }