Esempio n. 1
0
 public static bool SaveFromController(this IReactiveDbContext ctx, Func <IHttpActionResult> ok, Func <string, IHttpActionResult> badRequest, out IHttpActionResult result)
 {
     try
     {
         ctx.SaveChanges();
         var errors = (ctx as ReactiveDbContext).GetValidationErrors();
         if (errors.Count() > 0)
         {
             StringBuilder sb = new StringBuilder();
             errors.ToList().ForEach(e =>
             {
                 e.ValidationErrors.ToList().ForEach(v =>
                 {
                     sb.AppendLine(v.ErrorMessage);
                 });
             });
             result = badRequest(sb.ToString());
             return(false);
         }
         result = ok();
         return(true);
     }catch (DbUpdateException e)
     {
         result = badRequest(e.Message);
         return(false);
     }
 }
Esempio n. 2
0
 internal static bool RaiseDbValidationContextError(this IReactiveDbContext context, ValidationEntitiesException ex)
 {
     if (context.ValidationErrorCountSubscriber == 0)
     {
         return(true);
     }
     context.RaiseValidationError(ex);
     return(true);
 }
Esempio n. 3
0
 internal static bool RaiseDbContextError(this IReactiveDbContext context, Exception ex)
 {
     if (context.ErrorCountSubscriber == 0)
     {
         return(false);
     }
     context.RaiseError(ex);
     return(true);
 }
Esempio n. 4
0
 public ValidationEntitiesEventArg(IReactiveDbContext context, List <IValidationEntityError> errors)
 {
     this.Context = context;
     this.Errors  = errors;
 }
Esempio n. 5
0
 public ReactiveDbContextEventArgs(IReactiveDbContext sender, Exception ex)
 {
     this.Sender    = sender;
     this.Exception = ex;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReactivePropertyChangedEventArgs{TSender}"/> class.
 /// </summary>
 /// <param name="sender">The sender.</param>
 public ReactiveDbContextEventArgs(IReactiveDbContext sender) : this(sender, null)
 {
 }