예제 #1
0
 public Result <PostingItem> AddItemDetails(PostingItem posting)
 {
     return(GenerateDetails(posting).Bind(details =>
     {
         posting.DetailItems = details;
         return Result <PostingItem> .Ok(posting);
     }));
 }
예제 #2
0
 public Result <IEnumerable <PostingDetailItem> > GenerateDetails(PostingItem posting) =>
 _queryCodeMapperDetailQuery.FindAsync().Result
 .Bind(result =>
 {
     var newMappings = result.Select(item => new PostingDetailItem
     {
         PostingId     = posting.Id,
         ActionCodeId  = item.ActionCodeId,
         EffectiveDate = posting.EndDate,
         EntityState   = ItemState.Added
     });
     return(Result <IEnumerable <PostingDetailItem> > .Ok(newMappings));
 })
 .Bind(s => Save(s))
 .Bind(x => GetDetails(posting.Id));
예제 #3
0
        public Result <int> Save(PostingItem entity)
        {
            switch (entity.EntityState)
            {
            case ItemState.Added:
                return(_commandRepository.Add(entity.MapTo <Postings>()).MapResultTo <int, object>());

            case ItemState.Modified:
                return(_commandRepository.InlineUpdate(entity, entity.Id));

            case ItemState.Delete:
                return(_commandRepository.Delete(entity.Id));

            case ItemState.Unchanged:
                return(Result <int> .Fail <int>("Unchanged Object. Nothing to save"));

            default:
                return(Result <int> .Fail <int>("Entity state unknown"));
            }
        }
예제 #4
0
        public Result <PostingItem> Save(PostingItem entity)
        {
            switch (entity.EntityState)
            {
            case ItemState.Added:
                return(_repositoryCommand.Save(entity).Bind(id => _repositoryQuery.GetById(id))
                       .Bind <PostingItem>(item => _serviceDetails.AddItemDetails(item)));

            case ItemState.Modified:
                return(GetById(entity.Id));

            case ItemState.Delete:
                return(Result <PostingItem> .Fail <PostingItem>("Not Implemented Exception on Delete state"));

            case ItemState.Unchanged:
                return(Result <PostingItem> .Fail <PostingItem>("Not Implemented Exception on Unchanged state"));

            default:
                return(Result <PostingItem> .Fail <PostingItem>("Wrong entity state"));
            }
        }
예제 #5
0
 public Result <IEnumerable <PostingDetailItem> > Put([FromBody] PostingItem posting)
 {
     return(_services.GenerateDetails(posting));
 }
예제 #6
0
 public Result <PostingItem> Put(int id, [FromBody] PostingItem value)
 {
     return(_services.Save(value));
 }