示例#1
0
        public async Task <IActionResult> storeSendTestNotification(string DeviceId, string Message)
        {
            fcmNotification objfcmNotification = new fcmNotification();

            objfcmNotification.storeNotification(DeviceId, Message, "", "test");
            string myJson = "{\"Message\": " + "\"Notification Sent Successfully\"" + "}";

            return(Ok(myJson));
        }
示例#2
0
        public async Task <IActionResult> deliveryboyassignPost(deliveryboyAssignorderViewModel model)
        {
            if (ModelState.IsValid)
            {
                orders obj = _ordersServices.GetById(model.id);// await _usermanager.GetUserAsync(User);

                if (obj == null)
                {
                    TempData["error"] = "Order Not Found";
                }
                else
                {
                    if (string.IsNullOrEmpty(Convert.ToString(obj.deliveryboyid)))
                    {
                        obj.deliveryboyid = model.deliveryboyid;
                        obj.acceptedby    = "Admin";
                        await _ordersServices.UpdateAsync(obj);

                        var          driverdetails   = _driverRegistrationServices.GetById(model.deliveryboyid);
                        orderhistory objorderhistory = new orderhistory();
                        objorderhistory.oid         = model.id;
                        objorderhistory.placedate   = DateTime.UtcNow;
                        objorderhistory.orderstatus = "Admin assign Order to this Delivery boy." + driverdetails.name + "  . OrderID  :" + model.id;
                        await _orderhistoryServices.CreateAsync(objorderhistory);

                        #region "Notification customer and store"
                        int             customerid         = obj.customerid;
                        string          customerDeviceId   = _CustomerRegistrationservices.GetById(customerid).deviceid;
                        string          customerMsg        = driverdetails.name + " will be Delivering Your order";
                        string          customerTitle      = "Delivering Your order";
                        fcmNotification objfcmNotification = new fcmNotification();
                        objfcmNotification.customerNotification(customerDeviceId, customerMsg, "", customerTitle);

                        var    storeDeviceId = _usermanager.Users.Where(x => x.Id == obj.storeid).FirstOrDefault().deviceid;
                        string storeMsg      = "Admin Assign delivery boy " + driverdetails.name + " to this Order Id : " + model.id;
                        string storeTitle    = "Assign Deliveryboy";
                        objfcmNotification.storeNotification(storeDeviceId, storeMsg, "", storeTitle);

                        #endregion

                        TempData["success"] = "Order Assign To Delivery boy Successfully";
                        //string myJson = "{\"message\": " + "\"Order Assign To Delivery boy Successfully\"" + "}";
                        //return Ok(obj);
                    }
                    else
                    {
                        TempData["error"] = "This Order Id Already assign delivery boy";
                        //string myJson = "{\"message\": " + "\"This Order Id Already assign delivery boy\"" + "}";
                        //return BadRequest(myJson);
                    }
                }
            }
            return(RedirectToAction("test"));
        }