}
[AcceptVerbs (HttpVerbs.Post)] ActionResult Add (string itemName, string description, string contacts)
{(itemName == null && itemName.Length <3) ModelState.AddModelError ("ItemName", "Ім'я виробника має бути більше 2 символів!"); (description == null && description.Length <3) ModelState.AddModelError ("Description", "Опис повинен бути більше 2 символів!");
(ModelState.IsValid)
{i = _dataManager.Items.CreateItem (itemName, description); RedirectToAction ("Edit", new {id = i.ItemId});
} View ();
}
}
}
Контролер для проізводітелейSystem;
using System.Collections.Generic; System.Linq; System.Web; System.Web.Mvc; FurnitureCatalog.Models;
FurnitureCatalog.Controllers
{class ProducerController: Controller
{DataManager _dataManager;
ProducerController (DataManager dataManager)
{
_dataManager = dataManager;
}
//
// GET:/Producer/
ActionResult List ()
{["Title"] = "Список виробників"; ["Producers"] = _dataManager.Producers.GetProducers (); ["ProducersReverse"] = _dataManager.Producers.GetProducersReverse ( );
View ();
}
ActionResult List2 ()
{["Title"] = "Список виробників"; ["Producers"] = _dataManager.Producers.GetProducers (); ["ProducersReverse"] = _dataManager.Producers.GetProducersReverse ( );
View ();
}
ActionResult Producer (int id)
{
. Model = _dataManager.Producers.GetProducer (id); View ();
}
ActionResult Delete (int id)
{
_dataManager.Producers.DeleteProducer (id); RedirectToAction ("List");
}
[AcceptVerbs (HttpVerbs.Get)] ActionResult Edit (int id)
{s = _dataManager.Producers.GetProducer (id);
. Model = s; (s); View ();
}
void SetEditLists (Producers s)
{["Countries"] = new SelectList (_dataManager.Countries.GetCountries (), "CountryId", "CountryName", s.CountryId); ["FurnitureTypes"] = new SelectList (_dataManager.BusinessTypes.GetBusinessTypes (), "BusinessTypeId", "BusinessTypeName",. FurnitureTypeId);
}
[AcceptVerbs (HttpVerbs.Post)] ActionResul...