public async Task <IActionResult> Manage(Guid ApplicationUserId) { TradeCodeViewModel model = new TradeCodeViewModel(); model.ApplicationUser = await UserManagerService.FindByIdAsync(ApplicationUserId.ToString()); model.CurrentTradeCodesAssignedToUser = TradeCodeService.CurrentTradeCodesAssignedToUser(ApplicationUserId); ViewBag.TradeCodes = new SelectList(TradeCodeService.AllAvailableTradeCodesByUser(ApplicationUserId), "Id", "TradeType"); return(View(model)); }
public async Task <IActionResult> Assign(TradeCodeViewModel model, Guid ApplicationUserId) { ApplicationUser user = await UserManagerService.FindByIdAsync(ApplicationUserId.ToString()); TradeCode tradeCode = TradeCodeService.ReturnSingleTradeCode(model.TradeCodeToAssign.Id); RepairOperative RepairOperative = new RepairOperative { ApplicationUser = user, Id = Guid.NewGuid(), TradeCode = tradeCode }; TradeCodeService.AssignTradeCode(RepairOperative); TradeCodeService.SaveChanges(); return(RedirectToAction("Manage", new { ApplicationUserId = ApplicationUserId })); }