// GET: ModelMasterController/Create public async Task <ActionResult> Create() { var model = new VarientMasterModel(); var colourList = await _colourMasterService.GetAllColoursListAsync(); foreach (var item in colourList) { model.AvaillabelColoursList.Add(new SelectListItem { Value = item.Id.ToString(), Text = item.ColourName }); } return(View(model)); }
public async Task <ActionResult> Create(VarientMasterModel model, bool continueEditing) { try { var varientInfo = new VarientMaster { VarientCode = model.VarientCode, VerientName = model.VerientName, FriendlyName = model.FriendlyName, Active = model.Active, Deleted = false, DateUpdated = DateTime.UtcNow, DateCreated = DateTime.UtcNow, ByUser = Convert.ToInt32(HttpContext.User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.NameIdentifier)?.Value) }; await _verientMasterService.InsertAsync(varientInfo); foreach (var varColorMap in model.SelectedColourIds) { await _verientMasterService.AddMappingAsync(new ModelVarientColourMapping { VarientId = varientInfo.Id, ColourId = varColorMap }); } //if (continueEditing) // return RedirectToAction(nameof(Edit), new { id = modelInfo.Id }); TempData["UserMessageSuccess"] = "Record saved sucessfully."; return(RedirectToAction(nameof(List))); } catch (Exception ex) { TempData["UserMessageError"] = ex.Message.ToString(); return(RedirectToAction(nameof(Create))); } }