public async Task <ItemGroupFormViewModel> GetItemGroupForm(string itemGroupId) { var itemGroupForm = new ItemGroupFormViewModel() { ItemGroup = Mapper.Map <ItemGroupViewModel>(await _itemGroupRepository.GetItemGroup(itemGroupId)) }; return(itemGroupForm); }
public async Task <ActionResult> SaveItemGroupRecord(ItemGroupFormViewModel itemGroupForm) { if (ModelState.IsValid) { itemGroupForm.ItemGroup.UserId = User.Identity.GetUserId(); var recordsSaved = await _itemGroupService.SaveItemGroup(itemGroupForm.ItemGroup); if (recordsSaved >= 1) { var itemGroup = await _itemGroupService.GetItemGroup(itemGroupForm.ItemGroup.ItemGroupId); return(View("ItemGroupRecord", itemGroup)); } ModelState.AddModelError(string.Empty, "There was a problem and the ItemGroup was not saved."); } itemGroupForm = await _itemGroupService.GetItemGroupForm(itemGroupForm.ItemGroup.ItemGroupId); return(View("EditItemGroupRecord", itemGroupForm)); }