Exemple #1
0
        /// <summary>
        /// 获取单个店铺
        /// </summary>
        /// <param name="context"></param>
        private void GetSingleShop(HttpContext context)
        {
            Model.Shops s    = _IShopsBLL.GetSingleShops(Convert.ToInt32(context.Request["S_ID"]));
            string      json = JsonConvert.SerializeObject(s);

            context.Response.Write(json);
        }
        public async Task <ActionResult> SubmitNote(NoteDTO noteDTO)
        {
            List <ShopModel> shops = await userCosmosDBService.GetShops(noteDTO.Category);

            if (shops?.Count > 0)
            {
                List <ShopModel> nearbyShops      = DistanceCalculator.GetDistance(shops, noteDTO.Latitude, noteDTO.Longitude);
                string           body             = string.Format("You have received a new order request from {0}", noteDTO.UserPhoneNumber);
                var phoneGuidList                 = nearbyShops.Where(s => s.PhoneGuid != null)?.Select(shop => shop.PhoneGuid).ToList();
                NotificationData notificationData = null;
                var data = new Dictionary <string, string>();
                data.Add("orderid", "test");
                if (phoneGuidList.Count() > 0)
                {
                    if (phoneGuidList.Count() == 1)
                    {
                        notificationData = new NotificationData()
                        {
                            msgBody   = body,
                            msgTitle  = "You have received a new order request",
                            tokenList = phoneGuidList[0]
                                        //options = data
                        };
                    }
                    else
                    {
                        notificationData = new NotificationData()
                        {
                            msgBody   = body,
                            msgTitle  = "You have received a new order request",
                            tokenList = phoneGuidList
                                        //options = data
                        };
                    }

                    pushNotificationService.SendNotification(notificationData);
                }

                //Mapping
                NoteModel  note       = mapper.Map <NoteModel>(noteDTO);
                ShopsModel shopsModel = new ShopsModel();
                shopsModel.ShopModel = nearbyShops;
                Model.Shops shopsresult = mapper.Map <Model.Shops>(shopsModel);
                note.Shops = shopsresult.Shop;

                //Assigning fields
                note.NoteTime = DateTime.Now;
                note.Status   = 0;

                note = await noteCosmosDBService.CreateAndReturnDocumentAsync(note);

                if (note != null)
                {
                    return(Ok(mapper.Map <NoteInfo>(note)));
                }
            }
            return(Ok("No shops found with the matching criteria"));
        }
Exemple #3
0
        public bool InsertAdminUser(Users u, Model.Shops s)
        {
            string sql = "P_SetShopsAdmin";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",            u.S_ID),
                new SqlParameter("@US_ID",           u.S_ID),
                new SqlParameter("@U_LoginName",     u.U_LoginName),
                new SqlParameter("@S_IsHasSetAdmin", s.S_IsHasSetAdmin),
                new SqlParameter("@U_PassWord",      u.U_Password),
                new SqlParameter("@U_Role",          u.U_Role),
                new SqlParameter("@U_CanDelete",     u.U_CanDelete)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
Exemple #4
0
        /// <summary>
        /// 删除店铺
        /// </summary>
        /// <param name="context"></param>
        public void DeleteShop(HttpContext context)
        {
            Model.Shops s = new Model.Shops();
            s.S_ID = Convert.ToInt32(context.Request["S_ID"]);
            string i;

            if (_IShopsBLL.DeleteShops(s))
            {
                i = "1";
            }
            else
            {
                i = "0";
            }
            context.Response.Write(i);
        }
Exemple #5
0
        /// <summary>
        /// 修改店铺
        /// </summary>
        /// <param name="context"></param>
        public void UpdateShops(HttpContext context)
        {
            Model.Shops s = new Model.Shops();
            s.S_Name        = context.Request["S_Name"];
            s.S_Category    = Convert.ToInt32(context.Request["S_Category"]);
            s.S_ContactName = context.Request["S_ContactName"];
            s.S_ContactTel  = context.Request["S_ContactTel"];
            s.S_Address     = context.Request["S_Address"];
            s.S_Remark      = context.Request["S_Remark"];
            s.S_ID          = Convert.ToInt32(context.Request["S_ID"]);
            string i;

            if (_IShopsBLL.UpdateShops(s))
            {
                i = "1";
            }
            else
            {
                i = "0";
            }
            context.Response.Write(i);
        }
Exemple #6
0
        /// <summary>
        /// 新增店铺
        /// </summary>
        /// <param name="context"></param>
        public void InsertShop(HttpContext context)
        {
            Model.Shops s = new Model.Shops();
            s.S_Name          = context.Request["S_Name"];
            s.S_Category      = Convert.ToInt32(context.Request["S_Category"]);
            s.S_ContactName   = context.Request["S_ContactName"];
            s.S_ContactTel    = context.Request["S_ContactTel"];
            s.S_Address       = context.Request["S_Address"];
            s.S_Remark        = context.Request["S_Remark"];
            s.S_CreateTime    = DateTime.Now;
            s.S_IsHasSetAdmin = false;
            string i = "";

            if (_IShopsBLL.InsertShops(s))
            {
                i = "1";
            }
            else
            {
                i = "0";
            }
            context.Response.Write(i);
        }
Exemple #7
0
        /// <summary>
        /// 分配管理员
        /// </summary>
        /// <param name="context"></param>
        public void SetShopsAdmin(HttpContext context)
        {
            Model.Shops s = new Model.Shops();
            Model.Users u = new Model.Users();
            s.S_ID            = Convert.ToInt32(context.Request["S_ID"]);
            s.S_IsHasSetAdmin = true;
            u.S_ID            = Convert.ToInt32(context.Request["S_ID"]);
            u.U_LoginName     = context.Request["U_LoginName"];
            u.U_Password      = "******";
            u.U_Role          = 2;
            u.U_CanDelete     = true;
            var i = "";

            if (_IShopsBLL.InsertAdminUser(u, s))
            {
                i = "1";
            }
            else
            {
                i = "0";
            }
            context.Response.Write(i);
        }