Praveen Kumar

Praveen Kumar

  • NA
  • 235
  • 22.1k

How to call second Action result in first Actionresult?

Apr 11 2020 6:41 AM
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(ContactDetailViewModel model)
{
try
{
User user = _Login.GetCurrentUser();
using (var dbContextScope = _dbContextScopeFactory.Create())
{
Contact contact = model;
_ContactRepo.UpdateContact(contact, user);
dbContextScope.SaveChanges();
}
}
catch (RMException rme)
{
rme.Log();
ModelState.AddModelError("", "Saving contact failed. Please check your values and try again.");
return PartialView(model);
}
catch (Exception)
{
ModelState.AddModelError("", "Saving contact failed for an unknown reason. Please check your values and try again.");
return PartialView(model);
}
return RedirectToAction("Index", "Contact");
}
 
-----------------------------------------------------------------------------------------------------------------------------------
 
public ActionResult UpdateContactAttribute(int key, String values)
{
using (var dbContextScope = _dbContextScopeFactory.Create())
{
var dbAttribute = _ContactRepo.GetContactAttribute(key);
ContactViewModel.ContactAddressViewModel cvm = dbAttribute;
JsonConvert.PopulateObject(values, cvm);
User user = _Login.GetCurrentUser();
_ContactRepo.UpdateContactAttribute(cvm, user);
dbContextScope.SaveChanges();
}
return new HttpStatusCodeResult(HttpStatusCode.Created);
}
 
 

Answers (1)