How to get newly inserted id on OnResultExecuted

Posted: July 19, 2019 at 12:35 AM Quote #242670
Hi all,

I need help.

How to get inserted Id on "OnResultExecuted" event

My code is this.

public override void OnResultExecuted(ResultExecutedContext context)
{
  if (!(context.ActionDescriptor is ControllerActionDescriptor actionDescriptor)) return;

  if (actionDescriptor.ControllerTypeInfo == typeof([controllerName]) &&
    (actionDescriptor.ActionName == "Create" || actionDescriptor.ActionName == "Edit") &&
    context.HttpContext.Request.Method == "POST")
  {
    var data = context.HttpContext.Request.Form["Id"];
    var data1 = context.HttpContext.Request.Form["Text1"];
    var data2 = context.HttpContext.Request.Form["Text2"];
    return;
  }
  else
  {
    return;
  }
}

At the time of edit I get the id but at the time of create I can't get the Id field.
Is there any way to get the Id.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Thanks & Regards,
Pankaj Dobariya
-----------------------------------------------
Skype : pankaj_dobariya
Email : [email protected]
Posted: July 19, 2019 at 8:54 AM Quote #242681
You would have to listen for an event on the particular entity you working with.

ID's and generally created server side and not parsed through ajax or form requests.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: July 22, 2019 at 11:46 PM Quote #242766
Hi All,

I want to save some extra fields on GenericAttribute at the time of Create or update.
Is there there any way to do this?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Thanks & Regards,
Pankaj Dobariya
-----------------------------------------------
Skype : pankaj_dobariya
Email : [email protected]
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more