예제 #1
0
        public virtual UpsertResult <TDomain> Upsert(TDomain domain)
        {
            var saved = Set
                        .FindOptional(domain.Id)
                        .CreateIfNone()
                        .MapFrom(domain)
                        .MatchNew <TEntity, TKey>(entity => Set.Add(entity))
                        .Do(Context.SaveChanges)
                        .Map(entity => GetById(entity.Id))
                        .ValueOrFailure();

            return(UpsertResult <TDomain> .Ok(saved));
        }
예제 #2
0
        public override UpsertResult <IbanDomain> Upsert(IbanDomain domain)
        {
            domain.IbanStr = domain.IbanStr?.Replace(" ", "");

            var saved = Set
                        .FindOptional(domain.Id)
                        .CreateIfNone()
                        .MapFrom(domain)
                        .MatchNew <Iban, long>(entity => Set.Add(entity))
                        .Do(Context.SaveChanges)
                        .Map(entity => GetById(entity.Id))
                        .ValueOrFailure();

            return(UpsertResult <IbanDomain> .Ok(saved));
        }