Exemple #1
0
        public async void UpdateUserInTraining(DAL.App.DTO.UserInTraining userInTraining)
        {
            var usr = await RepoDbSet.FindAsync(userInTraining.Id);

            usr.AttendingTraining = userInTraining.AttendingTraining;
            RepoDbSet.Update(usr);
        }
Exemple #2
0
        public async Task <DTO.WorkoutRoutine> ChangeRoutinePublishStatus(Guid routineId, bool isPublished)
        {
            var routineToPublish = await RepoDbSet.FindAsync(routineId);

            routineToPublish.CreatedAt = isPublished ? DateTime.Now : DateTime.MaxValue;
            RepoDbSet.Update(routineToPublish);
            return(Mapper.MapDomainToDAL(routineToPublish));
        }
        public async Task <DAL.App.DTO.Notification> UpdateNotification(DAL.App.DTO.Notification notification)
        {
            var domain = await RepoDbSet.FindAsync(notification.Id);

            domain.Recived = true;
            var addedNotification = RepoDbSet.Update(domain).Entity;

            return(NotificationMapper.Map(addedNotification));
        }
Exemple #4
0
        public async Task <DALLoanDTO> FindAsync(int loanId)
        {
            var loan = await RepoDbSet.FindAsync(loanId);

            if (loan == null)
            {
                return(null);
            }
            return(LoanMapper.FromDomain2(loan));
        }
        public async Task <DALReceiptRowDTO> FindAsync(int rowId)
        {
            var row = await RepoDbSet.FindAsync(rowId);

            if (row == null)
            {
                return(null);
            }
            return(ReceiptRowMapper.FromDomain2(row, DateTime.Now));
        }
        public async Task <bool> RemoveSoft(int productId)
        {
            var product = await RepoDbSet.FindAsync(productId);

            if (product == null)
            {
                return(false);
            }
            product.IsDeleted = true;
            return(true);
        }
        public async Task <bool> RemoveSoft(int changeId)
        {
            var change = await RepoDbSet.FindAsync(changeId);

            if (change == null)
            {
                return(false);
            }
            change.IsDeleted = true;
            return(true);
        }
Exemple #8
0
        public async Task <DALOrganizationDTO> FindMinDTOAsync(int id)
        {
            var organization = await RepoDbSet.FindAsync(id);

            if (organization == null || organization.IsDeleted)
            {
                return(null);
            }

            return(OrganizationMapper.FromDomain2(organization));
        }
Exemple #9
0
        public async Task ChangeStatusAsync(int loanId, LoanStatus newStatus)
        {
            var loan = await RepoDbSet.FindAsync(loanId);

            if (loan == null)
            {
                throw new NullReferenceException("Didn't find Loan");
            }

            loan.Status = newStatus;
        }
Exemple #10
0
        public async Task <bool> SetFinalized(int receiptId)
        {
            var receipt = await RepoDbSet.FindAsync(receiptId);

            if (receipt == null)
            {
                return(false);
            }
            receipt.IsFinalized = true;
            receipt.CreatedTime = DateTime.Now;
            return(true);
        }
Exemple #11
0
        public override async Task <LoanRow> FindAsync(params object[] id)
        {
            var loanRow = await RepoDbSet.FindAsync(id);

            if (loanRow != null)
            {
                await RepoDbContext.Entry(loanRow).Reference(l => l.ReceiptRow).LoadAsync();

                await RepoDbContext.Entry(loanRow).Reference(l => l.Loan).LoadAsync();
            }

            return(loanRow);
        }
        public override async Task <ReceiptRow> FindAsync(params object[] id)
        {
            var receiptRow = await RepoDbSet.FindAsync(id);

            if (receiptRow != null)
            {
                await RepoDbContext.Entry(receiptRow).Reference(row => row.Product).LoadAsync();

                await RepoDbContext.Entry(receiptRow).Reference(row => row.Receipt).LoadAsync();
            }

            return(receiptRow);
        }
Exemple #13
0
        public override async Task <Price> FindAsync(params object[] id)
        {
            var price = await RepoDbSet.FindAsync(id);

            if (price != null)
            {
                await RepoDbContext.Entry(price).Reference(p => p.Change).LoadAsync();

                await RepoDbContext.Entry(price).Reference(p => p.Product).LoadAsync();
            }

            return(price);
        }
        public override async Task <ReceiptRowChange> FindAsync(params object[] id)
        {
            var rowChange = await RepoDbSet.FindAsync(id);

            if (rowChange != null)
            {
                await RepoDbContext.Entry(rowChange).Reference(rowC => rowC.Change).LoadAsync();

                await RepoDbContext.Entry(rowChange).Reference(rowC => rowC.ReceiptRow).LoadAsync();
            }

            return(rowChange);
        }
Exemple #15
0
        public override async Task <ReceiptParticipant> FindAsync(params object[] id)
        {
            var participant = await RepoDbSet.FindAsync(id);

            if (participant != null)
            {
                await RepoDbContext.Entry(participant).Reference(p => p.AppUser).LoadAsync();

                await RepoDbContext.Entry(participant).Reference(p => p.Receipt).LoadAsync();
            }

            return(participant);
        }
Exemple #16
0
        public async Task <DALReceiptDTO> FindReceiptAsync(int receiptId)
        {
            var receipt = await RepoDbSet.FindAsync(receiptId);

            if (receipt == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(receipt).Collection(r => r.ReceiptParticipants).LoadAsync();

            await RepoDbContext.Entry(receipt).Reference(r => r.ReceiptManager).LoadAsync();

            return(ReceiptMapper.FromDomain2(receipt));
        }
Exemple #17
0
        public override async Task <Loan> FindAsync(params object[] id)
        {
            var loan = await RepoDbSet.FindAsync(id);

            if (loan != null)
            {
                await RepoDbContext.Entry(loan).Reference(l => l.LoanGiver).LoadAsync();

                await RepoDbContext.Entry(loan).Reference(l => l.LoanTaker).LoadAsync();

                await RepoDbContext.Entry(loan).Reference(l => l.ReceiptParticipant).LoadAsync();
            }

            return(loan);
        }
Exemple #18
0
        public override async Task <ProductInCategory> FindAsync(params object[] id)
        {
            var productInCategory = await RepoDbSet.FindAsync(id);

            if (productInCategory != null)
            {
                await RepoDbContext.Entry(productInCategory).Reference(obj => obj.Product).LoadAsync();

                await RepoDbContext.Entry(productInCategory).Reference(obj => obj.Category).LoadAsync();

                await RepoDbContext.Entry(productInCategory.Category).Reference(obj => obj.Organization).LoadAsync();
            }

            return(productInCategory);
        }
Exemple #19
0
        public async Task <DALLoanRowDTO> FindAsync(int loanRowId)
        {
            var loanRow = await RepoDbSet.FindAsync(loanRowId);

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

            await RepoDbContext.Entry(loanRow).Reference(l => l.Loan).LoadAsync();

            await RepoDbContext.Entry(loanRow.Loan).Reference(l => l.ReceiptParticipant).LoadAsync();

            await RepoDbContext.Entry(loanRow.Loan.ReceiptParticipant).Reference(l => l.Receipt).LoadAsync();

            return(LoanRowMapper.FromDomain(loanRow));
        }
        public async Task <DALChangeDTO> EditAsync(DALChangeDTO changeDTO)
        {
            var change = await RepoDbSet.FindAsync(changeDTO.Id);

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

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

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


            change.ChangeName.SetTranslation(changeDTO.Name);

            return(ChangeMapper.FromDomain(change));
        }
        /// <summary>
        /// Edits products name and description, then returns productDTO
        /// </summary>
        /// <param name="dalProductDTO"></param>
        /// <returns></returns>
        public async Task <DALProductDTO> EditAsync(DALProductDTO dalProductDTO)
        {
            var product = await RepoDbSet.FindAsync(dalProductDTO.Id);

            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();

            product.ProductDescription.SetTranslation(dalProductDTO.Description);
            product.ProductName.SetTranslation(dalProductDTO.Name);

            return(ProductMapper.FromDomain(product));
        }