public ActionResult Create() { List <Business.Entities.owner> listOwner = RepoOwner.FindAll(); CustomerFormStub formStub = new CustomerFormStub(listOwner); formStub.FillTypeOptions(); formStub.FillTitleOptions(); formStub.IdOwner = GetOwnerId(); return(View("Form", formStub)); }
public ActionResult Edit(Guid id) { customer customer = RepoCustomer.FindByPk(id); List <Business.Entities.owner> listOwner = RepoOwner.FindAll(); CustomerFormStub formStub = new CustomerFormStub(customer, listOwner); formStub.FillTypeOptions(); formStub.FillTitleOptions(); ViewBag.name = customer.name; return(View("Form", formStub)); }
public ActionResult Index() { EnumHelper enumHelper = new EnumHelper(); var model = new CustomerFormStub(); List <SelectListItem> TypeCustomerOptions = new List <SelectListItem>(); foreach (CustomerType item in enumHelper.EnumToList <CustomerType>().ToList()) { TypeCustomerOptions.Add(new SelectListItem { Value = item.ToString(), Text = enumHelper.GetEnumDescription(item) }); } ViewBag.ListTypeCustomer = new JavaScriptSerializer().Serialize(TypeCustomerOptions); ViewBag.ListName = new JavaScriptSerializer().Serialize(model.NameOptions); return(View()); }
public ActionResult Edit(CustomerFormStub model) { //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0; if (ModelState.IsValid) { customer dbItem = RepoCustomer.FindByPk(model.Id); dbItem = model.GetDbObject(dbItem); try { RepoCustomer.Save(dbItem); } catch (Exception e) { model.FillOwnerOptions(RepoOwner.FindAll()); model.FillTypeOptions(); model.FillTitleOptions(); return(View("Form", model)); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.Name, template); return(RedirectToAction("Index")); } else { customer customer = RepoCustomer.FindByPk(model.Id); ViewBag.name = customer.name; model.FillOwnerOptions(RepoOwner.FindAll()); model.FillTypeOptions(); model.FillTitleOptions(); return(View("Form", model)); } }