コード例 #1
0
        public ActionResult BlockCustomer(Guid id)
        {
            //UserPermissionAction("Account", RoleAction.detail.ToString());
            //CheckPermission();
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            Customer objCustomer = _CustomerService.GetCustomer(id);

            try
            {
                if (objCustomer != null)
                {
                    objCustomer.IsActive = false;
                    _CustomerService.UpdateCustomer(objCustomer);
                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = "Account successfully deactivated.";
                    CommonCls.SendMailOfAccountIsActive(objCustomer.FirstName, objCustomer.EmailId, "deactivated");
                    string UserMessage = "Your account has been deactivated by admin.";
                    string Message     = "{\"flag\":\"" + "Deactivate" + "\",\"UserMessage\":\"" + UserMessage + "\"}";

                    var customerTo = objCustomer;

                    if (customerTo.ApplicationId != null && customerTo.ApplicationId != "")
                    {
                        if (customerTo.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            //Send Notification another Andriod
                            CommonCls.SendFCM_Notifications(customerTo.ApplicationId, Message, true);
                        }
                        else
                        {
                            string Msg = UserMessage;

                            CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, Msg, true);
                        }
                    }
                    return(RedirectToAction("Individuals"));
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.LogError(ex);
                RedirectToAction("Individuals");
            }
            return(RedirectToAction("Individuals"));
        }
コード例 #2
0
        public HttpResponseMessage SaveChat([FromBody] ChatModel chatModel)
        {
            string ChatID = "-1";

            try
            {
                if (chatModel.CustomerIdBy == new Guid())
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "CustomerId By is blank."), Configuration.Formatters.JsonFormatter));
                }
                if (chatModel.CustomerIdTo == new Guid())
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "CustomerId To is blank."), Configuration.Formatters.JsonFormatter));
                }
                var customerTo = _CustomerService.GetCustomer(chatModel.CustomerIdTo);
                if (customerTo == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer To not found."), Configuration.Formatters.JsonFormatter));
                }
                var customerBy = _CustomerService.GetCustomer(chatModel.CustomerIdBy);
                if (customerBy == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer By not found."), Configuration.Formatters.JsonFormatter));
                }
                if (chatModel.ChatContent != null && chatModel.ChatContent != "")
                {
                    List <Guid?> ListCustomerIDs = new List <Guid?>();
                    ListCustomerIDs.Add(chatModel.CustomerIdBy);
                    ListCustomerIDs.Add(chatModel.CustomerIdTo);


                    var isFriend = _RequestService.GetRequests().Where(x => ListCustomerIDs.Contains(x.CustomerIdBy) && ListCustomerIDs.Contains(x.CustomerIdTo)).FirstOrDefault();
                    if (isFriend != null)
                    {
                        Mapper.CreateMap <HomeHelp.Models.ChatModel, HomeHelp.Entity.Chat>();
                        HomeHelp.Entity.Chat chat = Mapper.Map <HomeHelp.Models.ChatModel, HomeHelp.Entity.Chat>(chatModel);
                        if (chatModel.ChatId <= 0)
                        {
                            TimeZoneInfo tz = TimeZoneInfo.Local;
                            chat.DateTimeCreated = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now, tz);
                            _ChatService.Insert(chat); //Save Operation
                            ChatID = chat.ChatId.ToString();
                        }

                        // Code For GCM & Iphone
                        //var Customer = _CustomerService.GetCustomer(Convert.ToInt32(chatModel.CustomerIdTo));
                        //if (Customer != null)
                        //{
                        //    var Chats = _ChatService.GetAll().ToList();
                        //    var Results = (from m in Chats
                        //                   where m.CustomerIdTo == chatModel.CustomerIdTo && m.IsRead == false
                        //                   group m by new { m.CustomerIdTo } into g
                        //                   select new
                        //                   {
                        //                       CustomerIdBy = g.Key.CustomerIdTo,
                        //                       ChatContent = (from c in Chats
                        //                                      where c.CustomerIdTo == chatModel.CustomerIdTo && c.IsRead == false
                        //                                      orderby c.DateTimeCreated descending
                        //                                      select c.ChatContent).FirstOrDefault(),
                        //                       Count = g.Count()
                        //                   }).ToList();

                        //    var models = new List<ChatModel>();

                        //    var UserMessage = "";
                        //    bool NotificationStatus = true;
                        //    if (Results.Count() >= 0)
                        //    {
                        //        int MessageCount = Convert.ToInt32(Results.Sum(x => x.Count).ToString()) + 1;
                        string UserMessage = "You have new message.";

                        string NotificationType = "chat";
                        string Flag             = "NewChatMessage";

                        //Save notification in Table
                        Notification Notification = new Notification();
                        Notification.NotificationId = 0; //New Case
                        //Notification.ClientId = _Event.ClientID; Save it as NULL
                        Notification.CustomerIdBy = customerBy.CustomerId;
                        Notification.CustomerIdTo = customerTo.CustomerId;
                        //Notification.EventID = _Event.EventID; Save it as NULL
                        Notification.UserMessage      = UserMessage;
                        Notification.NotificationType = NotificationType;
                        Notification.Flag             = Flag;
                        Notification.DeviceType       = customerBy.DeviceType;
                        _NotificationService.InsertNotification(Notification);
                        //        //End : Save notification in Table

                        // string Message = "{\"flag\":\"" + Flag + "\",\"message\":\"" + UserMessage + "\",\"ChatContent\":\"" + chatModel.ChatContent + "\"}";


                        string Message = "{ \"ChatId\": \"" + ChatID + "\",      \"CustomerIdBy\": \"" + customerBy.CustomerId + "\", \"CustomerIdTo\": \"" + customerTo.CustomerId + "\",      \"ChatContent\": \"" + chatModel.ChatContent
                                         + "\",      \"flag\": \"" + Flag + "\",      \"IsRead\": \"" + chat.IsRead + "\",     \"IsDeletedCustomerBy\":\"" + chat.IsDeletedCustomerBy
                                         + "\",      \"IsDeletedCustomerTo\": \"" + chat.IsDeletedCustomerTo + "\",     \"DateTimeCreated\": \""
                                         + chat.DateTimeCreated + "\",      \"CustomersBy\": { \"CustomerId\": \"" + customerBy.CustomerId
                                         + "\",       \"FirstName\": \"" + customerBy.FirstName + "\",        \"LastName\": \"" + customerBy.LastName
                                         + "\",       \"PhotoPath\": \"" + customerBy.PhotoPath + "\"      }, \"CustomersTo\": { \"CustomerId\": \"" + customerTo.CustomerId + "\",       \"FirstName\": \"" + customerTo.FirstName + "\",      \"LastName\": \"" + customerTo.LastName + "\",       \"PhotoPath\": \"" + customerTo.PhotoPath + "\"     }     }";


                        if (customerTo.ApplicationId != null && customerTo.ApplicationId != "")
                        {
                            if (customerTo.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                            {
                                //Send Notification another Andriod
                                CommonCls.SendFCM_Notifications(customerTo.ApplicationId, Message, true);
                            }
                            else
                            {
                                string Msg = customerTo.FirstName + " " + customerTo.LastName + " : " + chat.ChatContent;

                                CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, Msg, true);
                                //CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, true);
                            }
                        }
                        Mapper.CreateMap <HomeHelp.Entity.Chat, HomeHelp.Models.ChatResponseModel>();
                        HomeHelp.Models.ChatResponseModel ChatModel = Mapper.Map <HomeHelp.Entity.Chat, HomeHelp.Models.ChatResponseModel>(chat);
                        string sqlFormattedDate = chat.DateTimeCreated.HasValue ? chat.DateTimeCreated.Value.ToString("yyyy-MM-dd HH:mm:ss.fff") : "";

                        ChatModel.DateTimeCreated = sqlFormattedDate;

                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", ChatModel), Configuration.Formatters.JsonFormatter));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "they are not associated."), Configuration.Formatters.JsonFormatter));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Chat content is blank."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try later"), Configuration.Formatters.JsonFormatter));
            }
        }
コード例 #3
0
        public ActionResult AssignRequest(Guid assignedId, int jobRequestId)
        {
            string UserMessage = "";
            string Flag        = "";

            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            if (assignedId == null || jobRequestId == 0)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                RequestModel requestModel = new RequestModel();
                Mapper.CreateMap <JobRequest, RequestModel>();
                var jobRequestDetail = _RequestService.GetRequest(jobRequestId);
                var customerToData   = _AgencyIndividualService.GetAgencyIndividual(assignedId);
                var data             = _CustomerService.GetCustomerByUserId(customerToData.UserId);
                int id = Convert.ToInt32(Session["UserId"].ToString());
                if (id > 0)
                {
                    var assignedBy = _AgencyIndividualService.GetAgencyIndividualByUserId(id);
                    UserMessage = "You have new job request by " + assignedBy.FullName;
                    Flag        = "NewRequest";
                    Notification notification = new Notification();
                    notification.CustomerIdBy = assignedBy.AgencyIndividualId;

                    //notification.CustomerIdTo = data.CustomerId;
                    notification.CustomerIdTo = data.CustomerId;

                    notification.SourceId    = jobRequestDetail.JobRequestId;
                    notification.UserMessage = UserMessage;
                    //notification.NotificationType = Convert.ToString(EnumValue.NotificationType.Request);
                    notification.Flag               = Flag;
                    notification.DeviceType         = data.DeviceType;
                    notification.NotificationStatus = EnumValue.GetEnumDescription(EnumValue.RequestStatus.New);
                    _NotificationService.InsertNotification(notification);

                    string Message = "{\"flag\":\"" + Flag + "\",\"JobRequestId\":\"" + jobRequestDetail.JobRequestId + "\",\"UserMessage\":\"" + UserMessage + "\"}";

                    if (data.ApplicationId != null && data.ApplicationId != "")
                    {
                        if (data.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            //Send Notification another Andriod
                            CommonCls.SendFCM_Notifications(data.ApplicationId, Message, true);
                        }
                        else
                        {
                            string Msg = UserMessage;

                            CommonCls.TestSendFCM_Notifications(data.ApplicationId, Message, Msg, true);
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("LogOn", "Account"));
                }
                jobRequestDetail.CustomerIdTo = data.CustomerId;
                var assignedJob = _AgencyJobService.GetAgencyJobByJobRequest(jobRequestDetail.JobRequestId);
                assignedJob.AgencyIndividualId = data.CustomerId;
                if (jobRequestDetail.JobStatus == EnumValue.GetEnumDescription(EnumValue.RequestStatus.Declined))
                {
                    jobRequestDetail.RequestStatus = EnumValue.GetEnumDescription(EnumValue.RequestStatus.New);
                    jobRequestDetail.JobStatus     = EnumValue.GetEnumDescription(EnumValue.JobStatus.Pending);
                    assignedJob.Status             = EnumValue.GetEnumDescription(EnumValue.JobStatus.Pending);
                }

                _RequestService.UpdateRequest(jobRequestDetail);
                _AgencyJobService.UpdateAgencyJob(assignedJob);


                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        public HttpResponseMessage SaveReviewAndRating([FromBody] ReviewAndRatingModel ReviewAndRatingModel)
        {
            try
            {
                if (ReviewAndRatingModel.CustomerId == new Guid())
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Id is blank"), Configuration.Formatters.JsonFormatter));
                }

                if (ReviewAndRatingModel.JobRequestId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "JobRequest Id is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (ReviewAndRatingModel.Rating == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Rating is blank."), Configuration.Formatters.JsonFormatter));
                }
                //if (ReviewAndRatingModel.Rating > 5)
                //{
                //    return Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Rating cant be greater than 5."), Configuration.Formatters.JsonFormatter);
                //}



                var customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == ReviewAndRatingModel.CustomerId && c.IsActive == true).FirstOrDefault();
                if (customer != null)
                {
                    var job = _RequestService.GetRequest(ReviewAndRatingModel.JobRequestId);
                    if (job == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "job not found."), Configuration.Formatters.JsonFormatter));
                    }
                    if (job.JobStatus != EnumValue.GetEnumDescription(EnumValue.JobStatus.Completed))
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "job is not completed yet."), Configuration.Formatters.JsonFormatter));
                    }
                    var jobFound = _ReviewAndRatingService.GetReviewAndRatings().Where(f => f.CustomerId == ReviewAndRatingModel.CustomerId && f.JobRequestId == ReviewAndRatingModel.JobRequestId).FirstOrDefault();
                    if (jobFound == null)
                    {
                        Mapper.CreateMap <ReviewAndRatingModel, ReviewAndRating>();
                        ReviewAndRating reviewAndRating = Mapper.Map <ReviewAndRatingModel, ReviewAndRating>(ReviewAndRatingModel);
                        _ReviewAndRatingService.InsertReviewAndRating(reviewAndRating);

                        var    customerBy  = _CustomerService.GetCustomer(ReviewAndRatingModel.CustomerId);
                        string UserMessage = "You have new reviews.";

                        string NotificationType = "reviews";
                        string Flag             = "NewReviews";

                        //Save notification in Table
                        Notification Notification = new Notification();
                        Notification.NotificationId = 0; //New Case
                        //Notification.ClientId = _Event.ClientID; Save it as NULL
                        Notification.CustomerIdBy = customerBy.CustomerId;
                        //Notification.CustomerIdTo = customerTo.CustomerId;
                        //Notification.EventID = _Event.EventID; Save it as NULL
                        Notification.UserMessage      = UserMessage;
                        Notification.NotificationType = NotificationType;
                        Notification.Flag             = Flag;
                        Notification.DeviceType       = customerBy.DeviceType;
                        _NotificationService.InsertNotification(Notification);
                        //        //End : Save notification in Table
                        string ApplicationId = "";
                        string DeviceType    = "";
                        if (job.CustomerIdBy == customerBy.CustomerId)
                        {
                            ApplicationId = _CustomerService.GetCustomer(job.CustomerIdTo).ApplicationId;
                            DeviceType    = _CustomerService.GetCustomer(job.CustomerIdTo).DeviceType;
                        }
                        else
                        {
                            ApplicationId = _CustomerService.GetCustomer(job.CustomerIdBy).ApplicationId;
                            DeviceType    = _CustomerService.GetCustomer(job.CustomerIdBy).DeviceType;
                        }
                        string Message = "{\"flag\":\"" + Flag + "\",\"JobRequestId\":\"" + ReviewAndRatingModel.JobRequestId + "\",\"UserMessage\":\"" + UserMessage + "\"}";

                        if (ApplicationId != null && ApplicationId != "")
                        {
                            if (DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                            {
                                //Send Notification another Andriod
                                CommonCls.SendFCM_Notifications(ApplicationId, Message, true);
                            }
                            else
                            {
                                string Msg = UserMessage;

                                CommonCls.TestSendFCM_Notifications(ApplicationId, Message, Msg, true);
                            }
                        }

                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", "Reviews saved successfully."), Configuration.Formatters.JsonFormatter));
                    }
                    else
                    {
                        jobFound.Rating = (ReviewAndRatingModel.Rating != 0 ? ReviewAndRatingModel.Rating : jobFound.Rating);
                        jobFound.Review = (ReviewAndRatingModel.Review != null && ReviewAndRatingModel.Review != "") ? ReviewAndRatingModel.Review : jobFound.Review;
                        _ReviewAndRatingService.UpdateReviewAndRating(jobFound);
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", "Reviews updated successfully."), Configuration.Formatters.JsonFormatter));
                    }
                }

                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer not found."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try again."), Configuration.Formatters.JsonFormatter));
            }
        }