public ActionResult Edit(TypeViewModel typeVM) { try { if (ModelState.IsValid) { using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient()) { TypeDto typeDto = new TypeDto { Id = typeVM.Id, Name = typeVM.Name, Description = typeVM.Description }; service.PostType(typeDto); } return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
public static SelectList LoadTypesData() { using (TypeServiceReference.TypeClient typeService = new TypeServiceReference.TypeClient()) { SelectList selectListItems = new SelectList(typeService.GetTypes(), "Id", "Name"); return(selectListItems); } }
public ActionResult Delete(int id) { TypeViewModel typeVM = new TypeViewModel(); using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient()) { service.DeleteType(id); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { TypeViewModel typeVM = new TypeViewModel(); using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient()) { var typeDto = service.GetTypeById(id); typeVM = new TypeViewModel(typeDto); } return(View(typeVM)); }
// GET: Type public ActionResult Index() { List <TypeViewModel> typeVM = new List <TypeViewModel>(); using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient()) { foreach (var item in service.GetTypes()) { typeVM.Add(new TypeViewModel(item)); } } return(View(typeVM)); }