Beispiel #1
0
 public IResponseDTO WorkshopLogin(WorkshopVM model)
 {
     try
     {
         var res = _WorkshopRepositroy.GetFirst(X => X.Email == model.Email && X.Password == model.Password);
         if (res == null)
         {
             _response.Data     = null;
             _response.IsPassed = false;
             _response.Message  = "Not saved";
         }
         else
         {
             //var DbWorkshop = _mapper.Map<WorkshopVM>(res);
             //_response.Data = DbWorkshop;
             //_response.IsPassed = true;
             //_response.Message = "Ok";
             res.Token = model.Token;
             return(EditWorkshop(_mapper.Map <WorkshopVM>(res)));
         }
     }
     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 UpdateWorkshopNotificationsStatus(Guid NotificationId, bool IsRead)
        {
            try
            {
                var DbWorkshopNotifications = _WorkshopNotificationsRepositroy.GetFirst(x => x.NotificationId == NotificationId);
                DbWorkshopNotifications.IsRead = IsRead;
                var entityEntry = _WorkshopNotificationsRepositroy.Update(DbWorkshopNotifications);


                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);
        }
Beispiel #3
0
 public IResponseDTO AdminUsersLogin(AdminUsersVM model)
 {
     try
     {
         var res = _AdminUsersRepositroy.GetFirst(X => X.UserName == model.UserName && X.Password == model.Password);
         if (res == null)
         {
             _response.Data     = null;
             _response.IsPassed = false;
             _response.Message  = "Not saved";
         }
         else
         {
             var DbAdminUsers = _mapper.Map <AdminUsersVM>(res);
             _response.Data     = DbAdminUsers;
             _response.IsPassed = true;
             _response.Message  = "Ok";
         }
     }
     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 EditOrder(OrderVM model)
        {
            try
            {
                int OldStuts    = (int)_OrderRepositroy.GetFirst(x => x.OrderId == model.OrderId).Status;
                var DbOrder     = _mapper.Map <Order>(model);
                var entityEntry = _OrderRepositroy.Update(DbOrder);
                if (OldStuts != model.Status)
                {
                    bool _notification = SendNotification(model);
                }
                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 AdminUsersLogin(AdminUsersVM model)
 {
     try
     {
         var res = _AdminUsersRepositroy.GetFirst(X => X.UserName == model.UserName && X.Password == model.Password);
         if (res == null)
         {
             _response.Data     = null;
             _response.IsPassed = false;
             _response.Message  = "Not saved";
         }
         else
         {
             var DbAdminUsers = _mapper.Map <AdminUsersVM>(model);
             _response.Data     = DbAdminUsers;
             _response.IsPassed = true;
             _response.Message  = "Ok";
         }
     }
     catch (Exception ex)
     {
         _response.Data     = null;
         _response.IsPassed = false;
         _response.Message  = "Error " + ex.Message;
     }
     return(_response);
 }
Beispiel #6
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);
     }
 }
Beispiel #7
0
        public IResponseDTO CustomerMarketFollow(DTO.MarketFollowDTO model)
        {
            try
            {
                var currentFollow = _MarketFollowRepositroy.GetFirst(x => x.CustomerId == model.Customerid && x.MarketId == model.Marketid);
                if (currentFollow != null)
                {
                    currentFollow.Follow = model.Follow;
                    var entityEntry = _MarketFollowRepositroy.Update(currentFollow);
                }
                else
                {
                    var Follow = new MarketFollowVM()
                    {
                        //MarketCustomerId = Guid.NewGuid(),
                        CreationDate = DateTime.UtcNow.AddHours(3),
                        MarketId     = model.Marketid,
                        Follow       = model.Follow,
                        CustomerId   = model.Customerid,
                    };
                    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 GetAboutUs()
        {
            try
            {
                var AboutUss = _AboutUsRepositroy.GetFirst();

                var AboutUssList = _mapper.Map <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);
        }
 public IResponseDTO MarketLogin(DTO.MarketLoginDTO marketlogin)
 {
     try
     {
         var model = _MarketRepositroy.GetFirst(X => X.MarketEmail == marketlogin.MarketEmail && X.MarketPassword == marketlogin.MarketPassword);
         if (model == null)
         {
             _response.Data     = null;
             _response.IsPassed = false;
             _response.Message  = "Not saved";
         }
         else
         {
             model.Token = marketlogin.Token;
             var entityEntry = _MarketRepositroy.Update(model);
             int save        = _unitOfWork.Commit();
             var DbMarket    = _mapper.Map <MarketVM>(model);
             if (save == 200)
             {
                 _response.Data     = DbMarket;
                 _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);
 }
Beispiel #10
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);
     }
 }