Base solution for your next web application
Open Closed

Change DB value by property assignment #1848


User avatar
0
mgx92 created

Hello Community, I am new at asp.net boilerplate and it's a very nice framework :D

Now I have little problem: I wrote a mvc controller to manage my user data. This works very fine but when I am calling the following method: var user = await _userManager.GetUserByIdAsync(model.UserId);

i get an user object and when I am change a property like this: user.Notification = model.Notification;

it will change the db value without calling a saving method or something else. I want to change this behavior but I don't find any solution for this.

The GetUserByIdAsync method is out of the AbpUserManager-Class so that i cannot see whats happend.


2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    First of all, welcome to ABP community :).

    By default, ABP's AppServices and MVC Controllers (derived from ABP controller base) are unitOfWork. It means that, every change in unitOfWork methods are committed when the method is exited. You can find more info here about unit of work <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work">http://aspnetboilerplate.com/Pages/Docu ... it-Of-Work</a>.

    Why do you want to change that behaviour ?

  • User Avatar
    0
    mgx92 created

    Thank you :)

    Hmm.. okay.

    I think it's a danger to edit DB data at mvc controller level and I don't need to change data at the controller, because I would edit them at the application service.

    But when this is standard, it's okay :D