I am trying to update the entity only by the values sent to the API dynamically, so each time the client will send to my api different values it will change only the given values.
This is my entity
public class Administrator
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Role { get; set; }
public int Phone { get; set; }
}
This is my repository:
public Task<bool> UpdateAdmin(Administrator admin)
{
if (admin != null)
{
_context.Admins.Update(admin);
Commit();
return Task.FromResult(true);
}
else
{
return Task.FromResult(false);
}
}
Lets say I want to update only the phone number, I send the data with only new phone number but the rest of the properties are changed to null aswell. How can I update only the given ones?
Thanks