public IResponseDTO PostWorkshopTechnician(WorkshopTechnicianVM model)
        {
            try
            {
                var DbWorkshopTechnician = _mapper.Map <WorkshopTechnician>(model);

                var WorkshopTechnician = _mapper.Map <WorkshopTechnicianVM>(_WorkshopTechnicianRepositroy.Add(DbWorkshopTechnician));

                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);
        }
Exemplo n.º 2
0
        public IResponseDTO PostMarketFollow(MarketFollowVM model)
        {
            try
            {
                var DbMarketFollow = _mapper.Map <MarketFollow>(model);

                var MarketFollow = _mapper.Map <MarketFollowVM>(_MarketFollowRepositroy.Add(DbMarketFollow));

                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 " + ex.Message;
            }


            return(_response);
        }
        public IResponseDTO PostCustomerLogin(CustomerLoginVM model)
        {
            try
            {
                var DbCustomerLogin = _mapper.Map <CustomerLogin>(model);

                var CustomerLogin = _mapper.Map <CustomerLoginVM>(_CustomerLoginRepositroy.Add(DbCustomerLogin));

                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 " + ex.Message;
            }


            return(_response);
        }
Exemplo n.º 4
0
        public IResponseDTO PostContactUsMarket(ContactUsMarketVM model)
        {
            try
            {
                var DbContactUsMarket = _mapper.Map <ContactUsMarket>(model);
                var ContactUsMarket   = _mapper.Map <ContactUsMarketVM>(_ContactUsMarketRepositroy.Add(DbContactUsMarket));
                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 " + ex.Message;
            }
            return(_response);
        }
Exemplo n.º 5
0
        public IResponseDTO PostPrivacy(PrivacyVM model)
        {
            try
            {
                var DbPrivacy = _mapper.Map <Privacy>(model);
                var Privacy   = _mapper.Map <PrivacyVM>(_PrivacyRepositroy.Add(DbPrivacy));
                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 " + ex.Message;
            }
            return(_response);
        }
        public IResponseDTO PostAdvertisementCity(AdvertisementCityVM model)
        {
            try
            {
                var DbAdvertisement = _mapper.Map <AdvertisementCity>(model);

                var Advertisement = _mapper.Map <AdvertisementCityVM>(_AdvertisementCityRepositroy.Add(DbAdvertisement));

                int save = _unitOfWork.Commit();

                if (save == 200)
                {
                    _response.Data     = Advertisement;
                    _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 " + ex.Message;
            }


            return(_response);
        }
 public IResponseDTO GetAdvertisementDetails(Guid id, Guid CustomerId)
 {
     try
     {
         var Advertisements = _AdvertisementRepositroy.Get(x => x.AdsId == id,
                                                           includeProperties: "Market,AdvertisementCity,AdvertisementCity.City,AdvertisementCategory.Category,AdvertisementAttach").FirstOrDefault();
         if (Advertisements != null)
         {
             _AdvertisementOpenRepositroy.Add(new AdvertisementOpen()
             {
                 AdsOpenId  = Guid.NewGuid(),
                 AdsId      = Advertisements.AdsId,
                 CustomerId = CustomerId,
             });
             _unitOfWork.Commit();
         }
         var AdvertisementsList = _mapper.Map <AdvertisementIncloudVM>(Advertisements);
         _response.Data     = AdvertisementsList;
         _response.IsPassed = true;
         _response.Message  = "Done";
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + ex.Message;
     }
     return(_response);
 }
Exemplo n.º 8
0
        public IResponseDTO PostDepartment(DepartmentModel model)
        {
            try
            {
                var DbDepartment = _mapper.Map <Department>(model);

                var Department = _mapper.Map <DepartmentModel>(_departmentRepositroy.Add(DbDepartment));

                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 " + ex.Message;
            }


            return(_response);
        }
        public IResponseDTO PostCustomerNotifications(CustomerNotificationsVM model)
        {
            try
            {
                var DbCustomerNotifications = _mapper.Map <CustomerNotifications>(model);

                var CustomerNotifications = _mapper.Map <CustomerNotificationsVM>(_CustomerNotificationsRepositroy.Add(DbCustomerNotifications));

                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);
        }
Exemplo n.º 10
0
        public IResponseDTO PostAboutUs(AboutUsVM model)
        {
            try
            {
                var DbAboutUs = _mapper.Map <AboutUs>(model);
                var AboutUs   = _mapper.Map <AboutUsVM>(_AboutUsRepositroy.Add(DbAboutUs));
                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 " + ex.Message;
            }
            return(_response);
        }
 public IResponseDTO GetAdvertisementByCategory(int page, Guid categoryId, Guid cityId, Guid CustomerId)
 {
     try
     {
         var paging = new DTO.Pageing();
         paging.pageNumber = page;
         var Advertisements = _AdvertisementRepositroy.Get(x => x.Available == true,
                                                           includeProperties: "Market,AdvertisementCity,AdvertisementCategory")
                              .Skip(paging.skip).Take(paging.pageSize);
         var AdvertisementsList = new List <AdvertisementVM2>();
         foreach (var add in Advertisements)
         {
             var Category = add.AdvertisementCategory.FirstOrDefault(x => x.CategoryId == categoryId);
             if (Category == null)
             {
                 continue;
             }
             var City = add.AdvertisementCity.FirstOrDefault(x => x.CityId == cityId);
             if (City == null)
             {
                 continue;
             }
             _AdvertisementViewRepositroy.Add(new AdvertisementView()
             {
                 AdsViewId  = Guid.NewGuid(),
                 AdsId      = add.AdsId,
                 CustomerId = CustomerId,
             });
             AdvertisementsList.Add(_mapper.Map <AdvertisementVM2>(add));
         }
         _unitOfWork.Commit();
         //var AdvertisementsList = _mapper.Map<List<AdvertisementVM2>>(Advertisements);
         _response.Data     = AdvertisementsList;
         _response.IsPassed = true;
         _response.Message  = "Done";
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + ex.Message;
     }
     return(_response);
 }
Exemplo n.º 12
0
        public IResponseDTO SubscribeCustomer(DTO.CustomerSubscribeDTO model)
        {
            try
            {
                var customer = new CustomerVM()
                {
                    CustomerId   = Guid.NewGuid(),
                    CityId       = model.Cityid,
                    CreationDate = DateTime.UtcNow.AddHours(3),
                    Token        = model.Token,
                    Plateform    = model.Plateform,
                };
                var DbCustomer = _mapper.Map <Customer>(customer);

                var Customer = _mapper.Map <CustomerVM>(_CustomerRepositroy.Add(DbCustomer));

                int save = _unitOfWork.Commit();

                if (save == 200)
                {
                    _response.Data     = customer;
                    _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 " + ex.Message;
            }


            return(_response);
        }
Exemplo n.º 13
0
 public bool SendNotification(ChatVM model)
 {
     try
     {
         var    customer = _CustomerRepositroy.GetFirst(x => x.CustomerId == model.CustomerId);
         var    workshop = _WorkshopRepositroy.GetFirst(x => x.WorkshopId == model.WorkShopId);
         string _title = "", _message = "", _token = "";
         Dictionary <string, object> AdditionalData = new Dictionary <string, object>()
         {
             { "IsOrder", false },
             { "CustomerId", model.CustomerId },
             { "WorkshopId", model.WorkShopId },
         };
         if (model.IsCustomer == true)
         {
             _title   = customer.Name;
             _message = $"لقد وصلتك رسالة جديدة من  {customer.Name}";
             _token   = workshop.Token;
             _WorkshopNotificationsRepositroy.Add(_mapper.Map <WorkshopNotifications>(new WorkshopNotificationsVM()
             {
                 WorkshopId = model.WorkShopId,
                 Content    = _message,
                 Title      = _title,
             }));
         }
         else
         {
             _title   = workshop.Name;
             _token   = customer.Token;
             _message = $"لقد وصلتك رسالة جديدة من  {workshop.Name}";
             _CustomerNotificationsRepositroy.Add(_mapper.Map <CustomerNotifications>(new CustomerNotificationsVM()
             {
                 CustomerId = model.CustomerId,
                 Content    = _message,
                 Title      = _title,
             }));
         }
         Helper.NotificationHelper.PushNotificationByFirebase(_message, _title, new List <string>()
         {
             _token
         }, AdditionalData);
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : ""));
         return(false);
     }
 }
Exemplo n.º 14
0
 public IResponseDTO GetCategorysAds(Guid CustomerId)
 {
     try
     {
         var Categorys = _CategoryRepositroy.Get(includeProperties: "AdvertisementCategory").ToList();
         var ads       = _AdvertisementRepositroy.Get(x => x.Special == true && x.Available == true, includeProperties: "Market");
         List <CategoryVM> CategorysList = new List <CategoryVM>();// _mapper.Map<List<CategoryVM>>(Categorys);
         foreach (var c in Categorys)
         {
             if (c.AdvertisementCategory != null && c.AdvertisementCategory.Count > 0)
             {
                 CategorysList.Add(_mapper.Map <CategoryVM>(c));
             }
         }
         var adsList = _mapper.Map <List <AdvertisementVM2> >(ads);
         foreach (var add in ads)
         {
             _AdvertisementViewRepositroy.Add(new AdvertisementView()
             {
                 AdsViewId  = Guid.NewGuid(),
                 AdsId      = add.AdsId,
                 CustomerId = CustomerId,
             });
         }
         _unitOfWork.Commit();
         _response.Data = new DTO.AdsCategryDTO()
         {
             category = CategorysList,
             ads      = adsList,
         };
         _response.IsPassed = true;
         _response.Message  = "Done";
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + ex.Message;
     }
     return(_response);
 }
Exemplo n.º 15
0
        public IResponseDTO PostMarket(MarketVM model)
        {
            try
            {
                var res = _MarketRepositroy.Get(x => x.MarketEmail == model.MarketEmail);
                if (res != null)
                {
                    _response.Data     = null;
                    _response.IsPassed = false;
                    _response.Message  = "This email already exists";
                }
                var DbMarket = _mapper.Map <Market>(model);

                var Market = _mapper.Map <MarketVM>(_MarketRepositroy.Add(DbMarket));

                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 " + ex.Message;
            }
            return(_response);
        }
Exemplo n.º 16
0
 public bool SendNotification(OrderVM model)
 {
     try
     {
         var    customer = _CustomerRepositroy.GetFirst(x => x.CustomerId == model.CustomerId);
         var    workshop = _WorkshopRepositroy.GetFirst(x => x.WorkshopId == model.WorkshopId);
         string _title = "", _message = "", _token = "", _status = "";
         Dictionary <string, object> AdditionalData = new Dictionary <string, object>()
         {
             { "IsOrder", true },
             { "CustomerId", model.CustomerId },
             { "WorkshopId", model.WorkshopId },
             { "OrderId", model.OrderId },
         };
         if (model.IsCustomer == true)
         {
             _title = customer.Name;
             if (model.Status == 1)
             {
                 _status = "بدأ طلبيه جديد";
             }
             else if (model.Status == 2)
             {
                 _status = "استلام السيارة وفحصها والقبول التصليحات";
             }
             else if (model.Status == 3)
             {
                 _status = "بإلغاء الطلبيه";
             }
             _message = $"لقد قام العميل {customer.Name} بـ{_status}";
             _token   = workshop.Token;
             _WorkshopNotificationsRepositroy.Add(_mapper.Map <WorkshopNotifications>(new WorkshopNotificationsVM()
             {
                 WorkshopId = model.WorkshopId,
                 Content    = _message,
                 Title      = _title,
             }));
         }
         else
         {
             _title = workshop.Name;
             if (model.Status == 1)
             {
                 _status = "بدأ طلبيه جديد";
             }
             else if (model.Status == 2)
             {
                 _status = "اكمال الاصلاحات المطلوبة وانهاء الطلبيه";
             }
             else if (model.Status == 3)
             {
                 _status = "بإلغاء الطلبيه";
             }
             _message = $"لقد قامت ورشة {workshop.Name} بـ{_status}";
             _token   = workshop.Token;
             _CustomerNotificationsRepositroy.Add(_mapper.Map <CustomerNotifications>(new CustomerNotificationsVM()
             {
                 CustomerId = model.CustomerId,
                 Content    = _message,
                 Title      = _title,
             }));
         }
         Helper.NotificationHelper.PushNotificationByFirebase(_message, _title, new List <string>()
         {
             _token
         }, AdditionalData);
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1} ", ex.Message, ex.InnerException != null ? ex.InnerException.FullMessage() : ""));
         return(false);
     }
 }