Beispiel #1
0
        public IResponseDTO GetAllOrderAdmin()
        {
            try
            {
                var Orders = _OrderRepositroy.GetAll().Select(x => new {
                    OrderId      = x.OrderId,
                    Address      = x.Address,
                    CreationDate = x.CreationDate,
                    CustomerName = x.Customer.Name,
                    CustomerId   = x.CustomerId,
                    MapLangitude = x.MapLangitude,
                    MapLatitude  = x.MapLatitude,
                    Phone        = x.Phone,
                    Status       = x.Status,
                    WorkshopName = x.Workshop.Name,
                    WorkshopId   = x.WorkshopId,
                }).ToList();


                //var OrdersList = Orders;
                _response.Data     = Orders;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }
        public IResponseDTO EditWorkshopWorkTime(List <WorkshopWorkTimeVM> model)
        {
            try
            {
                var DbWorkshopWorkTime = _mapper.Map <List <WorkshopWorkTime> >(model);

                var workShopid = DbWorkshopWorkTime.FirstOrDefault().WorkshopId;
                var List       = _WorkshopWorkTimeRepositroy.GetAll(x => x.WorkshopId == workShopid);
                _WorkshopWorkTimeRepositroy.RemoveRange(List);
                _unitOfWork.Commit();
                _WorkshopWorkTimeRepositroy.AddRange(DbWorkshopWorkTime);
                int save = _unitOfWork.Commit();

                if (save == 200)
                {
                    _response.Data     = model;
                    _response.IsPassed = true;
                    _response.Message  = "Ok";
                }
                else
                {
                    _response.Data     = null;
                    _response.IsPassed = false;
                    _response.Message  = "Not saved";
                }
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }

            return(_response);
        }
        public IResponseDTO GetAllData()
        {
            try
            {
                var Cars         = _CarRepositroy.GetAll();
                var malfunctions = _MalfunctionRepositroy.GetAll();
                var features     = _FeaturesRepositroy.GetAll();

                var  CarsList        = _mapper.Map <List <CarVM> >(Cars);
                var  malfunctionList = _mapper.Map <List <MalfunctionVM> >(malfunctions);
                var  featuresList    = _mapper.Map <List <FeaturesVM> >(features);
                Data data            = new Data();
                data.cars          = CarsList;
                data.Features      = featuresList;
                data.malfunctions  = malfunctionList;
                _response.Data     = data;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }
Beispiel #4
0
 public IResponseDTO GetAllCity()
 {
     try
     {
         var Citys = from City in _CityRepositroy.GetAll()
                     select new
         {
             CityId       = City.CityId,
             Available    = City.Available,
             CityName     = City.CityName,
             CountryId    = City.Country.CountryId,
             CountryName  = City.Country.CountryName,
             CreationDate = City.CreationDate,
             Order        = City.Order,
         };
         var CitysList = Citys.ToList();
         _response.Data     = CitysList;
         _response.IsPassed = true;
         _response.Message  = "Done";
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
     }
     return(_response);
 }
        public IResponseDTO GetAllCar()
        {
            try
            {
                var Cars = _CarRepositroy.GetAll();

                var CarsList = _mapper.Map <List <CarVM> >(Cars);
                _response.Data     = CarsList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }
Beispiel #6
0
        public IResponseDTO GetAllDepartment()
        {
            var departments = _departmentRepositroy.GetAll();


            var departmentsList = _mapper.Map <List <DepartmentModel> >(departments);

            _response.Data     = departmentsList;
            _response.IsPassed = true;
            _response.Message  = "Done";
            return(_response);
        }
Beispiel #7
0
        public IResponseDTO GetAllWorkShopPreferAdmin()
        {
            try
            {
                var WorkShopPrefers = _WorkShopPreferRepositroy.GetAll().Select(x => new {
                    WorkShopPreferId = x.WorkShopPreferId,
                }).ToList();


                //var WorkShopPrefersList = WorkShopPrefers;
                _response.Data     = WorkShopPrefers;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }
        public IResponseDTO UpdateNotificationsStatus(Guid?id)
        {
            try
            {
                var DbCustomerNotifications = _CustomerNotificationsRepositroy.GetAll(x => x.CustomerId == id).ToList();
                foreach (var Notification in DbCustomerNotifications)
                {
                    Notification.IsRead = true;
                    _CustomerNotificationsRepositroy.Update(Notification);
                    _unitOfWork.Commit();
                }


                int save = _unitOfWork.Commit();

                if (save == 200)
                {
                    _response.Data     = null;
                    _response.IsPassed = true;
                    _response.Message  = "Ok";
                }
                else
                {
                    _response.Data     = null;
                    _response.IsPassed = false;
                    _response.Message  = "Not saved";
                }
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }

            return(_response);
        }
 public IResponseDTO GetAllCity()
 {
     try
     {
         var Citys     = _CityRepositroy.GetAll();
         var CitysList = _mapper.Map <List <CityVM> >(Citys);
         _response.Data     = CitysList;
         _response.IsPassed = true;
         _response.Message  = "Done";
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + ex.Message;
     }
     return(_response);
 }
        public IResponseDTO GetAllAboutUs()
        {
            try
            {
                var AboutUss = _AboutUsRepositroy.GetAll();

                var AboutUssList = _mapper.Map <List <AboutUsVM> >(AboutUss);
                _response.Data     = AboutUssList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
Beispiel #11
0
        public IResponseDTO GetAllContactUsMarket()
        {
            try
            {
                var ContactUsMarkets = _ContactUsMarketRepositroy.GetAll();

                var ContactUsMarketsList = _mapper.Map <List <ContactUsMarketVM> >(ContactUsMarkets);
                _response.Data     = ContactUsMarketsList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
Beispiel #12
0
        public IResponseDTO GetAllCategory()
        {
            try
            {
                var Categorys = _CategoryRepositroy.GetAll().OrderBy(y => y.Order).OrderBy(z => z.CategoryName);

                var CategorysList = _mapper.Map <List <CategoryVM> >(Categorys);
                _response.Data     = CategorysList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
        public IResponseDTO GetAllAdvertisementView()
        {
            try
            {
                var AdvertisementViews = _AdvertisementViewRepositroy.GetAll();


                var AdvertisementViewsList = _mapper.Map <List <AdvertisementViewVM> >(AdvertisementViews);
                _response.Data     = AdvertisementViewsList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
        public IResponseDTO GetAllCustomerLogin()
        {
            try
            {
                var CustomerLogins = _CustomerLoginRepositroy.GetAll();


                var CustomerLoginsList = _mapper.Map <List <CustomerLoginVM> >(CustomerLogins);
                _response.Data     = CustomerLoginsList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
Beispiel #15
0
        public IResponseDTO GetAllMarketFollow()
        {
            try
            {
                var MarketFollows = _MarketFollowRepositroy.GetAll();


                var MarketFollowsList = _mapper.Map <List <MarketFollowVM> >(MarketFollows);
                _response.Data     = MarketFollowsList;
                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
        public IResponseDTO GetAllWorkshopNotifications()
        {
            try
            {
                var WorkshopNotificationss = _WorkshopNotificationsRepositroy.GetAll();


                var WorkshopNotificationssList = _mapper.Map <List <WorkshopNotificationsVM> >(WorkshopNotificationss);
                var count = _WorkshopNotificationsRepositroy.Get(x => x.IsRead == false).Count();
                if (WorkshopNotificationss == null)
                {
                    //var WorkshopNotificationssList = _mapper.Map<WorkshopNotificationsVM>(WorkshopNotificationss);
                    _response.Data = new
                    {
                    };
                    _response.IsPassed = true;
                    _response.Message  = "Done";
                }
                else
                {
                    _response.Data = new
                    {
                        Notifications = WorkshopNotificationssList,
                        countNew      = count
                    };
                }

                _response.IsPassed = true;
                _response.Message  = "Done";
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }
Beispiel #17
0
        public IResponseDTO SearchWorkShop(Data data)
        {
            try
            {
                List <Guid>  carIds                 = null;
                List <Guid?> workshopCarIds         = null;
                List <Guid>  MalfunctionIds         = null;
                List <Guid?> workshopmalfunctionIds = null;
                List <Guid>  FeatureIds             = null;
                List <Guid?> workshopFeatureIds     = null;
                bool         HasSparePart           = data.HasSparePart;
                bool         HasWarranty            = data.HasWarranty;

                if (data.cars != null)
                {
                    carIds = data.cars.Select(c => c.CarId).ToList();
                    var WrokshopCar = _CarWorkshopRepositroy.GetAll().Where(w => carIds.Contains((Guid)w.CarId));
                    workshopCarIds = WrokshopCar.Select(c => c.WorkshopId).ToList();
                }
                if (data.malfunctions != null)
                {
                    MalfunctionIds = data.malfunctions.Select(c => c.MalfunctionId).ToList();
                    var Wrokshopmalfunction = _MalfunctionWorkshopRepositroy.GetAll().Where(w => MalfunctionIds.Contains((Guid)w.MalfunctionId));
                    workshopmalfunctionIds = Wrokshopmalfunction.Select(c => c.WorkshopId).ToList();
                }
                if (data.Features != null)
                {
                    FeatureIds = data.Features.Select(c => c.FeaturesId).ToList();
                    var WrokshopFeature = _FeaturesWorkshopRepositroy.GetAll().Where(w => FeatureIds.Contains((Guid)w.FeatureId));
                    workshopFeatureIds = WrokshopFeature.Select(c => c.WorkshopId).ToList();
                }

                var predicate    = PredicateBuilder.True <Workshop>();
                var oldPredicate = predicate;
                if (carIds != null)
                {
                    if (carIds.Count != 0)
                    {
                        predicate = predicate.And(w =>
                                                  workshopCarIds.Contains((Guid)w.WorkshopId));
                    }
                }
                if (MalfunctionIds != null)
                {
                    if (MalfunctionIds.Count != 0)
                    {
                        predicate = predicate.And(w =>
                                                  workshopmalfunctionIds.Contains((Guid)w.WorkshopId));
                    }
                }
                if (FeatureIds != null)
                {
                    if (FeatureIds.Count != 0)
                    {
                        predicate = predicate.And(w =>
                                                  workshopFeatureIds.Contains((Guid)w.WorkshopId));
                    }
                }


                var result = new List <Workshop>();
                //if (oldPredicate == predicate)
                //{
                //    result = new List<Workshop>();
                //}
                //else
                {
                    predicate = predicate.And(w => w.HasSparePart.Equals(HasSparePart) && w.HasWarranty.Equals(HasWarranty));


                    result = _WorkshopRepositroy.Get(predicate, includeProperties: "WorkshopRate,City").ToList();
                    // result = result.Where(x => x.HasSparePart.Equals(HasSparePart)&&x.HasWarranty.Equals(HasWarranty)).ToList();
                }


                if (result == null)
                {
                    _response.Data     = result;
                    _response.IsPassed = true;
                    _response.Message  = "Done";
                }
                else
                {
                    //_response.Data =_mapper.Map<List<WorkshopVM>>(result);
                    _response.Data = result.Select(x => new
                    {
                        Address      = x.Address,
                        CityId       = x.CityId,
                        CreationDate = x.CreationDate,
                        WorkshopId   = x.WorkshopId,
                        Name         = x.Name,
                        IsTrust      = x.IsTrust,
                        ImageUrl     = x.ImageUrl,
                        Token        = x.Token,
                        MapLatitude  = x.MapLatitude,
                        MapLangitude = x.MapLangitude,
                        Email        = x.Email,
                        Password     = "",
                        Phone        = x.Phone,
                        Info         = x.Info,
                        OwnerName    = x.OwnerName,
                        OwnerImage   = x.OwnerImage,
                        IsAvailable  = x.IsAvailable,
                        HasSparePart = x.HasSparePart,
                        HasWarranty  = x.HasWarranty,
                        RateCount    = x.WorkshopRate.Count,
                        RateAVG      = x.WorkshopRate.Count > 0 ? x.WorkshopRate.Average(y => y.Rate) : 0.0m,
                    }).ToList();
                    _response.IsPassed = true;
                    _response.Message  = "Done";
                }
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : "");
            }
            return(_response);
        }