I can't update customize entity

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi guys
I am a newbie and I would like guys help me an issue, please! I can't fix it.
Curently, I use Nop Ecomerce 3.9
- In Nop.Core, I have definded a domain with name "B_SIL_CFItem"
- In Nop.Data, I have created a mapping  To Table("B_SIL_CF");
- In Nop.Service, I have created IB_SIL_CFService and B_SIL_CFService to make CRUD functions
- In Nop.Web.Framwork, I add line into  DependencyRegistrar.cs
builder.RegisterType<B_SIL_CFService>().As<IB_SIL_CFService>().InstancePerLifetimeScope();
- Add some line at Nop.Admin.Infrastructure.Mapper.AdminMapperConfiguration.cs
- In Nop.Administrator, I have create View, Model, Controller
I can insert a row into table, but I can't update it
[HttpPost, ParameterBasedOnFormName("save-continue", "continueEditing")]
        [FormValueRequired("save", "save-continue")]
        [ValidateInput(false)]
        public virtual ActionResult Edit(B_SIL_CFModel model, bool continueEditing, FormCollection form)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                return AccessDeniedView();

            var obj = _b_SIL_CFService.GetByIdSILCF(model.Id);
            if (obj == null)
                return RedirectToAction("List");        

            if (ModelState.IsValid)
            {

                //var SILCF = ConvertToObject(model);
                obj = model.ToEntity();              
                obj.UPDATED_DATE = DateTime.UtcNow;
                _b_SIL_CFService.UpdateSILCF(obj);
                SuccessNotification(_localizationService.GetResource("Admin.SIL_CF.Updated"));
                
                if (continueEditing)
                {
                    return RedirectToAction("Edit", new { id = obj.Id });
                }
                return RedirectToAction("List");
            }
            PrepareSILCFModel(model, obj, true);
            return View(model);
        }


Please tell me why, I had read old topics but not success.
3 years ago
Update this line

obj = model.ToEntity();

to
obj = model.ToEntity(obj);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.