private ResponseBase SaveChangesToDb(KeyValuePair <Type, string> property, object value, object updateValue, SapphireDbContext db, HttpInformation context, UpdateCommand command) { property.Key.ExecuteHookMethods <UpdateEventAttribute>(v => v.Before, value, context, serviceProvider); property.Key.UpdateFields(value, updateValue, db, context, serviceProvider); if (!ValidationHelper.ValidateModel(value, serviceProvider, out Dictionary <string, List <string> > validationResults)) { return(new UpdateResponse() { UpdatedObject = value, ReferenceId = command.ReferenceId, ValidationResults = validationResults }); } db.Update(value); property.Key.ExecuteHookMethods <UpdateEventAttribute>(v => v.BeforeSave, value, context, serviceProvider); db.SaveChanges(); property.Key.ExecuteHookMethods <UpdateEventAttribute>(v => v.After, value, context, serviceProvider); return(new UpdateResponse() { UpdatedObject = value, ReferenceId = command.ReferenceId }); }
private ResponseBase ApplyChangesToDb(KeyValuePair <Type, string> property, object value, object updateValue, SapphireDbContext db, HttpInformation context) { property.Key.ExecuteHookMethods <UpdateEventAttribute>(ModelStoreEventAttributeBase.EventType.Before, value, context, serviceProvider); property.Key.UpdateFields(value, updateValue, db, context, serviceProvider); if (!ValidationHelper.ValidateModel(value, serviceProvider, out Dictionary <string, List <string> > validationResults)) { return(new UpdateResponse() { UpdatedObject = value, ValidationResults = validationResults }); } db.Update(value); property.Key.ExecuteHookMethods <UpdateEventAttribute>(ModelStoreEventAttributeBase.EventType.BeforeSave, value, context, serviceProvider); return(new UpdateResponse() { UpdatedObject = value }); }