/// <summary> /// Edit Product Width /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> Edit(int id) { ProductWidthViewModel model = await generateAPIResponse.ProductWidthViewRepo.GetByID("productWidth", id); if (model != null) { return(View("Create", model)); } else { return(RedirectToAction("Index")); } }
/// <summary> /// Save & Update Product Width Details with Post & Put Methods of the Web APIs. /// </summary> /// <param name="model"></param> /// <param name="action"></param> /// <returns></returns> private async Task <IActionResult> SaveProductWidthDetails(ProductWidthViewModel model, String action) { try { var response = false; // Call Post Method to Create New Product Width Details if (action.ToLower() == "create") { response = await generateAPIResponse.ProductWidthViewRepo.Save("productWidth", model); ViewBag.Message = "Product Width record has been created successfully."; } // Call Put Method to Update Existing Product Width Details else { response = await generateAPIResponse.ProductWidthViewRepo.Update("productWidth/" + model.ProductWidthID, model); ViewBag.Message = "Product Width record has been updated successfully."; } if (response) { ViewBag.Class = "text-success"; return(await RedirectToIndex()); } else { ViewBag.Message = null; return(View("Create", model)); } } catch (Exception ex) { ViewBag.Message = "Something went wrong: " + ex.Message; } return(View("Create", model)); }
public async Task <IActionResult> Create(ProductWidthViewModel model) { return(await SaveProductWidthDetails(model, "Create")); }
public async Task <IActionResult> Edit(ProductWidthViewModel model) { return(await SaveProductWidthDetails(model, "Edit")); }