public PagingListDetails <ProductCategory> Get(ProductCategorySearchFilter filter)
        {
            Expression <Func <ProductCategory, bool> > conditions = x => true;

            if (filter != null)
            {
                if (!string.IsNullOrWhiteSpace(filter.Name))
                {
                    conditions = x => x.Name.Contains(filter.Name);
                }
            }

            return(_productCategoryRepo.Get(conditions, filter, x => x.OrderByDescending(u => u.ProductCategoryId)));
        }
Example #2
0
        public PagingListDetails <Store> Get(StoreSearchFilter filter)
        {
            Expression <Func <Store, bool> > conditions = x => !x.IsDeleted;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (!string.IsNullOrWhiteSpace(filter.Name))
                {
                    conditions = conditions.And(x => x.FullName.Contains(filter.Name));
                }
            }

            return(_storeRepo.Get(conditions, filter, x => x.OrderByDescending(i => i.StoreId), new List <Expression <Func <Store, object> > > {
                x => x.User
            }));
        }
Example #3
0
        public PagingListDetails <Relative> Get(RelativeSearchFilter filter)
        {
            Expression <Func <Relative, bool> > conditions = x => true;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (!string.IsNullOrWhiteSpace(filter.NationalCode))
                {
                    conditions = conditions.And(x => x.NationalCode == filter.NationalCode);
                }
                if (!string.IsNullOrWhiteSpace(filter.Name))
                {
                    conditions = conditions.And(x => (x.Name + " " + x.Family).Contains(filter.Name));
                }
            }

            return(_RelativeRepo.Get(conditions, filter, x => x.OrderByDescending(u => u.RelativeId)));;
        }
        public PagingListDetails <BankAccount> Get(BankAccountSearchFilter filter)
        {
            Expression <Func <BankAccount, bool> > conditions = x => true;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (filter.Name != null)
                {
                    conditions = conditions.And(x => x.BankName == filter.Name);
                }
            }

            return(_BankAccountRepo.Get(conditions, filter, x => x.OrderByDescending(u => u.BankAccountId)));;
        }
        //public IResponse<PagingListDetails<AddressSearchFilter>> Get(Guid userId)
        //{
        //    var currentDT = DateTime.Now;
        //    var addresses = _addressRepo.Get(selector: a => new AddressSearchFilter
        //    {
        //        UserId = userId,
        //        Details = a.AddressDetails
        //    },
        //    conditions: x => x.UserId == userId,
        //    pagingParameter: new PagingParameter
        //    {
        //        PageNumber = 1,
        //        PageSize = 3
        //    },
        //    orderBy: o => o.OrderByDescending(x => x.AddressId));
        //    return new Response<PagingListDetails<AddressSearchFilter>>
        //    {
        //        Result = addresses,
        //        IsSuccessful = true
        //    };
        //}

        public PagingListDetails <Address> Get(AddressSearchFilter filter)
        {
            Expression <Func <Address, bool> > conditions = x => true;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (!string.IsNullOrWhiteSpace(filter.Details))
                {
                    conditions = conditions.And(x => x.AddressDetails.Contains(filter.Details));
                }
            }

            return(_addressRepo.Get(conditions, filter, x => x.OrderByDescending(u => u.AddressId), new System.Collections.Generic.List <Expression <Func <Address, object> > > {
                x => x.User
            }));
        }
Example #6
0
        public PagingListDetails <Order> Get(OrderSearchFilter filter)
        {
            Expression <Func <Order, bool> > conditions = x => true;

            if (filter != null)
            {
                if (filter.UserId != null)
                {
                    conditions = conditions.And(x => x.UserId == filter.UserId);
                }
                if (filter.StoreId != null)
                {
                    conditions = conditions.And(x => x.StoreId == filter.StoreId);
                }
                if (!string.IsNullOrWhiteSpace(filter.FromDateSh))
                {
                    var dt = PersianDateTime.Parse(filter.FromDateSh).ToDateTime();
                    conditions = conditions.And(x => x.InsertDateMi >= dt);
                }
                if (!string.IsNullOrWhiteSpace(filter.ToDateSh))
                {
                    var dt = PersianDateTime.Parse(filter.ToDateSh).ToDateTime();
                    conditions = conditions.And(x => x.InsertDateMi <= dt);
                }
                if (!string.IsNullOrWhiteSpace(filter.TransactionId))
                {
                    conditions = conditions.And(x => x.Payments.Any(p => p.TransactionId == filter.TransactionId));
                }
                if (filter.OrderStatus != null)
                {
                    conditions = conditions.And(x => x.OrderStatus == filter.OrderStatus);
                }
            }

            return(_orderRepo.Get(conditions, filter, x => x.OrderByDescending(i => i.OrderId), new System.Collections.Generic.List <Expression <Func <Order, object> > >
            {
                x => x.Store,
                x => x.ToAddress,
                x => x.User
            }));
        }
 public IResponse <string> DeleteRange(int LossId)
 {
     try
     {
         foreach (var asset in _lossAssetRepo.Get(conditions: x => x.LossId == LossId, null))
         {
             if (File.Exists(asset.PhysicalPath))
             {
                 File.Delete(asset.PhysicalPath);
             }
         }
         return(new Response <string> {
             IsSuccessful = true
         });
     }
     catch (Exception e)
     {
         FileLoger.Error(e);
         return(new Response <string> {
             Message = ServiceMessage.Error
         });
     }
 }
Example #8
0
 public IResponse <string> DeleteRange(int productId)
 {
     try
     {
         foreach (var asset in _productAssetRepo.Get(conditions: x => x.ProductId == productId, null))
         {
             if (File.Exists(asset.CdnFileUrl))
             {
                 File.Delete(asset.CdnFileUrl);
             }
         }
         return(new Response <string> {
             IsSuccessful = true
         });
     }
     catch (Exception e)
     {
         FileLoger.Error(e);
         return(new Response <string> {
             Message = ServiceMessage.Error
         });
     }
 }
Example #9
0
        public IResponse <PagingListDetails <AddressDTO> > Get(Guid userId)
        {
            var currentDT = DateTime.Now;
            var addresses = _addressRepo.Get(selector: a => new AddressDTO
            {
                Id      = a.AddressId,
                Lat     = a.Latitude,
                Lng     = a.Longitude,
                Address = a.AddressDetails
            },
                                             conditions: x => x.UserId == userId,
                                             pagingParameter: new PagingParameter
            {
                PageNumber = 1,
                PageSize   = 3
            },
                                             orderBy: o => o.OrderByDescending(x => x.AddressId));

            return(new Response <PagingListDetails <AddressDTO> >
            {
                Result = addresses,
                IsSuccessful = true
            });
        }
Example #10
0
 public IEnumerable <UserInRole> Get(Guid userId)
 => _userInRoleRepo.Get(x => x.UserId == userId,
                        x => x.OrderByDescending(uir => uir.UserId),
                        new List <Expression <Func <UserInRole, object> > > {
     x => x.Role
 }).ToList();
        public async Task <IHttpActionResult> AddBuild(NewPcBuild newPcBuild)
        {
            if (newPcBuild == null)
            {
                return(BadRequest("no model provided"));
            }
            PCBuildsEntity newUpdateItem = new PCBuildsEntity();


            newUpdateItem.Memory      = newPcBuild.Memory;
            newUpdateItem.DiskStorage = newPcBuild.DiskStorage;
            newUpdateItem.Graphics    = newPcBuild.Graphics;
            newUpdateItem.PowerSupply = newPcBuild.PowerSupply;
            newUpdateItem.PcWeight    = newPcBuild.PcWeight;
            newUpdateItem.Processors  = newPcBuild.Processors;

            if (newPcBuild.Id != 0)
            {
                newUpdateItem.Id = newPcBuild.Id;
                newUpdateItem    = await _pcBuildsRepository.Update(newUpdateItem);
            }
            else
            {
                newUpdateItem = await _pcBuildsRepository.Create(newUpdateItem);
            }


            var checkedUsbId = new List <int>();

            for (var i = 0; i < newPcBuild.Usbs.Count(); i++)
            {
                UsbToBuildEntity UsbToBuild = new UsbToBuildEntity();

                var x = newPcBuild.Usbs[i];
                if (x.Id != 0)
                {
                    UsbToBuild = await _usbToBuildRepo.Get(x.Id);

                    UsbToBuild.Usb      = x.Usb;
                    UsbToBuild.PcBuild  = newUpdateItem;
                    UsbToBuild.NumberOf = x.NumberOf;
                    UsbToBuild          = await _usbToBuildRepo.Update(UsbToBuild);
                }
                else
                {
                    UsbToBuild.Usb      = x.Usb;
                    UsbToBuild.PcBuild  = newUpdateItem;
                    UsbToBuild.NumberOf = x.NumberOf;
                    UsbToBuild          = await _usbToBuildRepo.Create(UsbToBuild);
                };
                checkedUsbId.Add(UsbToBuild.Id);
            }

            var UsbData = await _usbToBuildRepo.Get(x => x.PcBuild.Id == newPcBuild.Id);

            for (var i = 0; i < UsbData.Count(); i++)
            {
                if (checkedUsbId.Contains(UsbData[i].Id))
                {
                    continue;
                }
                else
                {
                    await _usbToBuildRepo.Delete(UsbData[i]);
                }
            }
            newUpdateItem.USBs = await _usbToBuildRepo.Get(x => x.PcBuild.Id == newPcBuild.Id);



            return(Ok(newUpdateItem));
        }
        public virtual TModel Get(TKey id)
        {
            var result = genericRepo.Get(id);

            return(result);
        }