t Edit (int id, Producers s)
{
(s.ProducerName.Length <3) ModelState.AddModelError ("ProducerName", "Ім'я виробника має бути більше 2 символів!"); (s.Description! = null & & s.Description.Length <3) ModelState.AddModelError ("Description", "Опис повинен бути більше 2 символів!");
(ModelState.IsValid)
{. ProducerId = id;
_dataManager.Producers.UpdateProducer (s); RedirectToAction ("List");
}
(s); View ();
}
[AcceptVerbs (HttpVerbs.Get)] ActionResult Add ()
{View ();
}
[AcceptVerbs (HttpVerbs.Post)] ActionResult Add (string producerName, string description, string contacts)
{(producerName == null && producerName.Length <3) ModelState.AddModelError ("ProducerName", "Ім'я виробника має бути більше 2 символів!"); (description == null && description.Length <3) ModelState.AddModelError ("Description", "Опис повинен бути більше 2 символів!");
(ModelState.IsValid)
{
_dataManager.Producers.CreateProducer (producerName, description, contacts); RedirectToAction ("List");
} View ();
}
}
}
Контролер для В«ПродавцівВ» System;
using System.Collections.Generic; System.Linq; System.Web; System.Web.Mvc; FurnitureCatalog.Models;
FurnitureCatalog.Controllers
{class SellerController: Controller
{DataManager _dataManager;
SellerController (DataManager dataManager)
{
_dataManager = dataManager;
}
//
// GET:/Seller/
ActionResult List ()
{["Title"] = "Список продавців"; ["Sellers"] = _dataManager.Sellers.GetSellers (); ["SellersReverse"] = _dataManager.Sellers.GetSellersReverse ( ); View ();
}
ActionResult List2 ()
{["Title"] = "Список продавців"; ["Sellers"] = _dataManager.Sellers.GetSellers (); ["SellersReverse"] = _dataManager.Sellers.GetSellersReverse ( ); View ();
}
ActionResult Seller (int id)
{
. Model = _dataManager.Sellers.GetSeller (id); View ();
}
ActionResult Delete (int id)
{
_dataManager.Sellers.DeleteSeller (id); RedirectToAction ("List");