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); } }
internal static bool RaiseDbValidationContextError(this IReactiveDbContext context, ValidationEntitiesException ex) { if (context.ValidationErrorCountSubscriber == 0) { return(true); } context.RaiseValidationError(ex); return(true); }
internal static bool RaiseDbContextError(this IReactiveDbContext context, Exception ex) { if (context.ErrorCountSubscriber == 0) { return(false); } context.RaiseError(ex); return(true); }
public ValidationEntitiesEventArg(IReactiveDbContext context, List <IValidationEntityError> errors) { this.Context = context; this.Errors = errors; }
public ReactiveDbContextEventArgs(IReactiveDbContext sender, Exception ex) { this.Sender = sender; this.Exception = ex; }
/// <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) { }