mercredi 28 février 2018

Approach for saving UI entities

I have a complex object that consists of several other objects. Example:

public class Car {
   public string Name;
   public int iWheelID {get;set;};
   public int AccessoriesList {get;set;};
}

public class Wheel {
   public int iWheelID {get;set;}
   public int Color {get;set;}
   public int Radius {get;set;}
}

public class Accessory {
   public int iAccessoryID {get;set;}
   public int Type {get;set;}
}

All objects are mapped to appropriate tables in database and appropriate UI objects.

Frontend contains editor for several cars (we can change wheels or accessories, color of wheel, type of accesory etc.) and all edits are saved only after "Save" clicking.

Please, give me an advise about how I should save the state of one car to database. Because of delayed saving, i can't save to database each edit that user performs. That's why when user clicks 'Save' i should send the WHOLE model to server and perform edits in database.

The simplest way - delete old state and save new state. But i don't think it's an effective approach. Is there any pattern for my case?

I am using C# MVC + EF

Aucun commentaire:

Enregistrer un commentaire