>}
[AcceptVerbs (HttpVerbs.Get)] ActionResult Edit (int id)
{s = _dataManager.Sellers.GetSeller (id);
. Model = s; (s); View ();
}
void SetEditLists (Sellers s)
{["Countries"] = new SelectList (_dataManager.Countries.GetCountries (), "CountryId", "CountryName", s.CountryId); ["BusinessTypes"] = new SelectList (_dataManager.BusinessTypes.GetBusinessTypes (), "BusinessTypeId", "BusinessTypeName",. BusinessTypeId);
}
[AcceptVerbs (HttpVerbs.Post)] ActionResult Edit (int id, Sellers s)
{
(s.SellerName.Length <3) ModelState.AddModelError ("SellerName", "Ім'я продавця повинно бути більше 2 символів!"); (s.Description! = null & & s.Description.Length <3) ModelState.AddModelError ("Description", "Опис повинен бути більше 2 символів!");
(ModelState.IsValid)
{. SellerId = id;
_dataManager.Sellers.UpdateSeller (s); RedirectToAction ("List");
}
(s); View ();
}
[AcceptVerbs (HttpVerbs.Get)] ActionResult Add ()
{View ();
}
[AcceptVerbs (HttpVerbs.Post)]
[Authorize (Roles = "Administrator")] ActionResult Add (string sellerName, string description, string contacts)
{(sellerName == null && sellerName.Length <3) ModelState.AddModelError ("SellerName", "Ім'я продавця повинно бути більше 2 символів!"); (description == null && description.Length <3) ModelState.AddModelError ("Description", "Опис повинен бути більше 2 символів!");
(ModelState.IsValid)
{
_dataManager.Sellers.CreateSeller (sellerName, description, contacts); RedirectToAction ("List");
} View ();
}
}
}
Контролер для В«Допомоги та пошукуВ»
using System; System.Collections.Generic; System.Linq; System.Web; System.Web.Mvc; FurnitureCatalog.Models;
FurnitureCatalog.Controllers
{
[HandleError] class HomeController: Controller
{DataManager _dataManager;
HomeController (DataManager dataManager)
{
_dataManager = dataManager;
}
ActionResult Index ()
{["Message"] = "Ласкаво просимо в електронний каталог меблів!"; ["Sellers"] = new SelectList (_dataManager.Sellers.GetSellers (), "Sell...