public IActionResult add(MenuTypeModel model) { try { if (ModelState.IsValid) { MenuTypeDto dto = new MenuTypeDto(); dto.menu_type_id = model.menu_type_id; dto.menu_category_id = model.menu_category_id; dto.name = model.name; _menuTypeService.save(dto); AlertHelper.setMessage(this, "Item Category saved successfully.", messageType.success); return(RedirectToAction("index")); } } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); return(RedirectToAction("new")); } var menuCategories = _menuCategoryRepo.getQueryable().Where(a => a.is_enabled == true).ToList(); ViewBag.categories = new SelectList(menuCategories, "menu_category_id", "name"); return(View(model)); }
public void save(MenuTypeDto menu_type_dto) { try { using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) { MenuType menuType = new MenuType(); _menuTypeMaker.copy(menuType, menu_type_dto); _menuTypeRepository.insert(menuType); tx.Complete(); } } catch (Exception) { throw; } }
public void update(MenuTypeDto menu_type_dto) { try { using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) { MenuType menu_type = _menuTypeRepository.getById(menu_type_dto.menu_type_id); if (menu_type == null) { throw new ItemNotFoundException($"Menu Type with ID {menu_type_dto.menu_type_id} doesnot Exit."); } _menuTypeMaker.copy(menu_type, menu_type_dto); _menuTypeRepository.update(menu_type); tx.Complete(); } } catch (Exception) { throw; } }
public void copy(MenuType menu_type, MenuTypeDto dto) { menu_type.menu_category_id = dto.menu_category_id; menu_type.menu_type_id = dto.menu_type_id; menu_type.name = dto.name; }