public static IEnumerable <ContractDto> GetContracts(Status status = Status.All)
        {
            using (var context = new PawnShopContext())
            {
                MapperInitiliazer.InitiliazeContracts();

                if (status == Status.All)
                {
                    var contracts =
                        context.Contracts
                        //.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name)
                        .ProjectTo <ContractDto>()
                        .ToList();

                    return(contracts);
                }

                var filtredContracts =
                    context.Contracts.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name && c.Status == status)
                    .ProjectTo <ContractDto>()
                    .ToList();

                return(filtredContracts);
            }
        }
        public static IEnumerable <ContractDto> GetContractsByTown(string town)
        {
            using (var context = new PawnShopContext())
            {
                MapperInitiliazer.InitiliazeContracts();

                var contracts = context.Contracts.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name && c.Employee.Office.Address.Town.Name == town)
                                .ProjectTo <ContractDto>()
                                .ToList();

                return(contracts);
            }
        }
        public static IEnumerable <ContractDto> GetContractsByClientsName(string name)
        {
            using (var context = new PawnShopContext())
            {
                MapperInitiliazer.InitiliazeContracts();

                var contracts = context.Contracts.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name && string.Concat(c.Client.FirstName, " ", c.Client.MiddleName, " ", c.Client.LastName) == name)
                                .ProjectTo <ContractDto>()
                                .ToList();

                return(contracts);
            }
        }
        public static IEnumerable <ContractDto> GetContractsByClientsPersonalId(int personalId)
        {
            using (var context = new PawnShopContext())
            {
                MapperInitiliazer.InitiliazeContracts();

                var contracts = context.Contracts.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name && c.Client.PersonalID == personalId)
                                .ProjectTo <ContractDto>()
                                .ToList();

                return(contracts);
            }
        }
Beispiel #5
0
        public static IEnumerable <ContractDto> GetContractsByAddress(string address)
        {
            using (var context = new PawnShopContext())
            {
                context.Users.Attach(LoginUser.User);
                MapperInitiliazer.InitiliazeContracts();

                var contracts = context.Contracts.Where(c => c.Employee.Office.Name == LoginUser.User.Office.Name && c.Client.Address.Text == address)
                                .ProjectTo <ContractDto>()
                                .ToList();

                return(contracts);
            }
        }