public async Task AddAsync(int changeId, int receiptRowId)
 {
     var receiptRowChange = new ReceiptRowChange()
     {
         ChangeId     = changeId,
         ReceiptRowId = receiptRowId
     };
     await RepoDbSet.AddAsync(receiptRowChange);
 }
Ejemplo n.º 2
0
        public async Task AddAsync(int changeId, int categoryId)
        {
            var obj = new ChangeInCategory()
            {
                ChangeId   = changeId,
                CategoryId = categoryId
            };

            await RepoDbSet.AddAsync(obj);
        }
 public async Task AddNewFeedback(DTO.Feedback feedback)
 {
     var domain = new Domain.Feedback
     {
         AppUserId = feedback.AppUserId,
         Content   = feedback.Content,
         Rating    = feedback.Rating
     };
     await RepoDbSet.AddAsync(domain);
 }
Ejemplo n.º 4
0
        public async Task AddAsync(int productId, int categoryId)
        {
            var obj = new ProductInCategory()
            {
                ProductId  = productId,
                CategoryId = categoryId
            };

            await RepoDbSet.AddAsync(obj);
        }
Ejemplo n.º 5
0
        public async Task <int?> AddAsync(DALReceiptDTO receiptDTO)
        {
            var receipt     = ReceiptMapper.FromDAL(receiptDTO);
            var addedEntity = (await RepoDbSet.AddAsync(receipt)).Entity;

            if (addedEntity == null)
            {
                return(null);
            }
            EntityCreationCache.Add(addedEntity.Id, addedEntity);
            return(addedEntity.Id);
        }
Ejemplo n.º 6
0
        public async Task AddAsync(int loanId, int receiptRowId, decimal involvement)
        {
            var loanRow = new LoanRow()
            {
                Involvement  = involvement,
                IsPaid       = false,
                LoanId       = loanId,
                ReceiptRowId = receiptRowId
            };

            await RepoDbSet.AddAsync(loanRow);
        }
Ejemplo n.º 7
0
        public async Task <DALChangeDTO> AddAsync(DALChangeDTO changeDTO)
        {
            var change = ChangeMapper.FromDAL(changeDTO);

            change = (await RepoDbSet.AddAsync(change)).Entity;
            if (change == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(change).Reference(c => c.ChangeName).LoadAsync();

            await RepoDbContext.Entry(change.ChangeName).Collection(c => c.Translations).LoadAsync();

            return(ChangeMapper.FromDomain(change));
        }
        /// <summary>
        /// Adds row
        /// </summary>
        /// <param name="row"></param>
        /// <param name="userId"></param>
        /// <returns>receiptRowId</returns>
        public async Task <int?> AddAsync(DALReceiptRowDTO row)
        {
            var receiptRow = ReceiptRowMapper.FromDAL(row);

            if (receiptRow == null)
            {
                return(null);
            }

            var receiptEntity = (await RepoDbSet.AddAsync(receiptRow)).Entity;

            EntityCreationCache.Add(receiptEntity.Id, receiptEntity);

            return(receiptEntity.Id);
        }
Ejemplo n.º 9
0
        public async Task <int> FindOrAddAsync(DALReceiptParticipantDTO participant, int receiptManagerId)
        {
            var loan = await RepoDbSet
                       .FirstOrDefaultAsync(obj => obj.ReceiptParticipantId == participant.Id);

            if (loan != null)
            {
                return(loan.Id);
            }

            return((await RepoDbSet.AddAsync(new Loan()
            {
                ReceiptParticipantId = participant.Id,
                LoanTakerId = participant.ParticipantAppUserId,
                LoanGiverId = receiptManagerId
            })).Entity.Id);
        }
Ejemplo n.º 10
0
        public async Task AddAsync(DALPriceDTO priceDTO)
        {
            if ((priceDTO.ChangeId != null && priceDTO.ProductId != null) ||
                (priceDTO.ChangeId == null && priceDTO.ProductId == null))
            {
                throw new ArgumentException("Both priceId and product id can't be null or both can't have a value");
            }
            var price = new Price()
            {
                Value     = priceDTO.Value,
                ChangeId  = priceDTO.ChangeId,
                ProductId = priceDTO.ProductId,
                ValidFrom = priceDTO.ValidFrom,
                ValidTo   = priceDTO.ValidTo
            };

            await RepoDbSet.AddAsync(price);
        }
Ejemplo n.º 11
0
        public async Task <DALReceiptParticipantDTO> FindOrAddAsync(int receiptId, int loanTakerId)
        {
            var participant = await RepoDbSet
                              .FirstOrDefaultAsync(obj => obj.AppUserId == loanTakerId && obj.ReceiptId == receiptId);

            if (participant != null)
            {
                return(ReceiptParticipantMapper.FromDomain(participant));
            }

            participant = (await RepoDbSet.AddAsync(new ReceiptParticipant
            {
                AppUserId = loanTakerId,
                ReceiptId = receiptId
            })).Entity;

            return(ReceiptParticipantMapper.FromDomain(participant));;
        }
Ejemplo n.º 12
0
        public async Task <DALProductDTO> AddAsync(DALProductDTO dto)
        {
            var product = ProductMapper.FromDAL(dto);

            product = (await RepoDbSet.AddAsync(product)).Entity;
            if (product == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(product).Reference(p => p.ProductName).LoadAsync();

            await RepoDbContext.Entry(product.ProductName).Collection(name => name.Translations).LoadAsync();

            await RepoDbContext.Entry(product).Reference(p => p.ProductDescription).LoadAsync();

            await RepoDbContext.Entry(product.ProductDescription).Collection(desc => desc.Translations).LoadAsync();


            return(ProductMapper.FromDomain(product));
        }
Ejemplo n.º 13
0
        public async Task EditAsync(DALPriceDTO priceDTO)
        {
            if ((priceDTO.ChangeId != null && priceDTO.ProductId != null) ||
                (priceDTO.ChangeId == null && priceDTO.ProductId == null))
            {
                throw new ArgumentException("Both priceId and product id can't be null or both can't have a value");
            }

            var time = priceDTO.ValidFrom;

            if (priceDTO.ProductId != null)
            {
                var oldPrice = await RepoDbSet
                               .Where(price => price.ValidTo > time && price.ValidFrom < time &&
                                      price.ProductId == priceDTO.ProductId)
                               .SingleOrDefaultAsync();

                oldPrice.ValidTo = time;
            }
            else
            {
                var oldPrice = await RepoDbSet
                               .Where(price => price.ValidTo > time && price.ValidFrom < time &&
                                      price.ChangeId == priceDTO.ChangeId)
                               .SingleOrDefaultAsync();

                oldPrice.ValidTo = time;
            }

            var newPrice = new Price()
            {
                Value     = priceDTO.Value,
                ChangeId  = priceDTO.ChangeId,
                ProductId = priceDTO.ProductId,
                ValidTo   = priceDTO.ValidTo,
                ValidFrom = priceDTO.ValidFrom
            };

            await RepoDbSet.AddAsync(newPrice);
        }
Ejemplo n.º 14
0
 public async Task AddAsync(DALOrganizationDTO organizationDTO)
 {
     await RepoDbSet.AddAsync(OrganizationMapper.FromDAL(organizationDTO));
 }
Ejemplo n.º 15
0
 public async Task AddNewTrainingInBill(DTO.TrainingInBill dto)
 {
     await RepoDbSet.AddAsync(TrainingInBillMapper.Map(dto));
 }
        public Bill AddNewBill(DAL.App.DTO.Bill bill)
        {
            var domain = RepoDbSet.AddAsync(BillMapper.MapToDomain(bill)).Result.Entity;

            return(BillMapper.Map((domain)));
        }
Ejemplo n.º 17
0
        public async Task AddAsync(DALCategoryDTO categoryDTO)
        {
            var category = CategoryMapper.FromDAL(categoryDTO);

            await RepoDbSet.AddAsync(category);
        }
        public async Task <DTO.NotificationAnswer> AddNewAnswer(DTO.NotificationAnswer answer)
        {
            var domain = NotificationAnswerMapper.MapToDomain(answer);

            return(NotificationAnswerMapper.Map((await RepoDbSet.AddAsync(domain)).Entity));
        }