/// <summary> /// 登出 /// </summary> /// <param name="phone"></param> /// <returns></returns> public Result <Account> SignOut(long phone) { Result <Account> result = new Result <Account>() { Status = false, Message = "登出失败,登出人员与当前账户不匹配", StatusCode = "SO001" }; IOnlineAccountCache service = ServiceObjectContainer.Get <IOnlineAccountCache>(); string key = string.Format("OnlineAI_{0}", phone); if (service.SearchInfoByKey(key) != null) { if (service.RemoveInfo(key)) { result.Status = true; result.Message = "登出成功"; result.StatusCode = "SO000"; //Todo :记录数据库 登出日志 } } return(result); }
public ActionResult Index(long phone) { //获取用户数据 ViewBag.Account = base.CurrentAccount; Account viewaccount = ServiceObjectContainer.Get <IAccountService>().GetAccountInfo(phone).Data; //获取用户的食谱列表 Result <IList <Recipes> > recipesresult = ServiceObjectContainer.Get <IRecipesService>().GetRecipesByPhone(phone); ViewBag.Recipes = recipesresult.Data; //获取用户分享的单品列表 Result <IList <Dish> > dishresult = ServiceObjectContainer.Get <IDishService>().GetShareDishList(phone); ViewBag.Dishs = dishresult.Data; //获取用户收藏的食谱 Result <IList <Recipes> > favoriteRecipes = ServiceObjectContainer.Get <IRecipesService>().GetFavoriteRecipesByPhone(phone); ViewBag.FavoriteRecipes = favoriteRecipes.Data; //获取用户收藏的单品 Result <IList <Dish> > favoritedishs = ServiceObjectContainer.Get <IDishService>().GetFavoriteDishByPhone(phone); ViewBag.FavoriteDishs = favoritedishs.Data; //用户收藏总数 ViewBag.FavoriteCount = favoriteRecipes.Data.Count + favoritedishs.Data.Count; return(View(viewaccount)); }
public ActionResult GenerateDishShareView() { //获取当前用户的食谱集 ViewBag.Recipes = ServiceObjectContainer.Get <IRecipesService>().GetRecipesByPhone(CurrentAccount.Phone).Data; ViewBag.Meal = (int)MealTime.所有时间段; return(View()); }
public JsonResult DishShare(Dish dish, int shopid, int recipeid) { IDishService dishservice = ServiceObjectContainer.Get <IDishService>(); IRecipesService recipesservice = ServiceObjectContainer.Get <IRecipesService>(); IShopService shopservice = ServiceObjectContainer.Get <IShopService>(); Shop shopselect = shopservice.GetShopInfoById(shopid).Data; Recipes recipesselect = recipesservice.GetRecipesById(recipeid).Data; dish.DishId = Generation.GenerationId(); dish.UpdateDate = DateTime.Now; dish.ShopId = shopselect.ShopId; dish.ShopName = shopselect.ShopName; if (!string.IsNullOrEmpty(dish.Image)) { int substringindex = dish.Image.LastIndexOf(',') + 1; dish.Image = dish.Image.Substring(substringindex, dish.Image.Length - substringindex); } DishShare share = new DishShare(); share.DishInfo = dish; share.RecipesInfo = recipesselect; share.ShopInfo = shopselect; return(Json(dishservice.ShareDishInfo(share))); }
public JsonResult ShareDish(int shopId, int recipesId) { IDishService dish = ServiceObjectContainer.Get <IDishService>(); IRecipesService recipes = ServiceObjectContainer.Get <IRecipesService>(); IShopService shop = ServiceObjectContainer.Get <IShopService>(); Shop shopselect = shop.GetShopInfoById(shopId).Data; Recipes recipesselect = recipes.GetRecipesById(recipesId).Data; Dish dishmodel = new Dish(); dishmodel.DishId = Generation.GenerationId(); dishmodel.Name = "黑椒牛柳"; dishmodel.Type = Model.Enum.DishType.川菜.GetHashCode(); dishmodel.MealTime = Model.Enum.MealTime.午餐.GetHashCode(); dishmodel.UpdateDate = DateTime.Now; dishmodel.Image = ""; dishmodel.Description = "测试单品"; dishmodel.ShopId = shopselect.ShopId; dishmodel.ShopName = shopselect.ShopName; DishShare share = new DishShare(); share.DishInfo = dishmodel; share.RecipesInfo = recipesselect; share.ShopInfo = shopselect; return(Json(dish.ShareDishInfo(share))); }
/// <summary> /// 根据编号精确获取单品食物 /// </summary> /// <param name="dishId">单品食物编号</param> /// <returns></returns> public Result <Dish> SearchDishInfoById(int dishId) { Result <Dish> result = new Result <Dish>() { Data = null, Status = true }; try { IDishCache service = ServiceObjectContainer.Get <IDishCache>(); DishInfo dishinfo = service.GetDishInfoById(dishId); if (dishinfo != null) { result.Data = dishinfo.Copy <Dish>(); result.Status = true; } else { result.Status = false; } } catch (Exception ex) { result.Status = false; result.Message = "查询单品食物出错:" + ex.Message; result.StatusCode = "SD001"; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SearchDishInfoById() .DishService"), LogType.ErrorLog); } return(result); }
public ActionResult Index() { ViewBag.Account = base.CurrentAccount; //创建分页参数 PageSearchParam param = new PageSearchParam(); param.PageIndex = 1; param.PageNumer = 4; //获取推荐单品信息 MealTime meal = GetMealTimeForNow(); Result <PageList <Dish> > dishresult = ServiceObjectContainer.Get <IDishService>().SearchDishInfoByMealTime(meal, param); ViewBag.DishList = dishresult.Data; //获取推荐食谱信息 Result <PageList <Recipes> > recipesresult = ServiceObjectContainer.Get <IRecipesService>().GetPageRecipes(param); ViewBag.RecipesList = recipesresult.Data; ViewBag.Meal = meal; return(View()); }
public JsonResult Getsss() { ITestService service = ServiceObjectContainer.Get <ITestService>(); Result result = service.TestFunction(); return(Json(result)); }
public JsonResult ShakeTodayDish(ShakeParam param) { param.NearDistance = 1000; //筛选附近店铺 Result <IList <Shop> > dishresult = ServiceObjectContainer.Get <IShakeService>().ShakeNearShops(param); return(Json(dishresult)); }
public JsonResult SearchKeyforShopInfo(string key) { Result <PageList <Shop> > result = ServiceObjectContainer.Get <IShopService>().SearchShopInfoByName(key, new PageSearchParam() { PageIndex = 1, PageNumer = 5 }); return(Json(result)); }
/// <summary> /// 主页页面 /// </summary> /// <returns></returns> public ActionResult Index() { //获取测试服务 ITestService service = ServiceObjectContainer.Get <ITestService>(); Result result = service.TestFunction(); return(View()); }
public Result TestFunction() { //获取测试服务 ITestService service = ServiceObjectContainer.Get <ITestService>(); Result result = service.TestFunction(); //sss return(result); }
/// <summary> /// 更新门店信息 /// </summary> /// <param name="shopInfo">门店信息</param> /// <returns>操作结果</returns> public Result UpdateShopInfo(Shop shopInfo) { Result result = new Result() { Status = true, Message = "更新门店成功" }; try { bool cannext = false; ShopInfo info = shopInfo.Copy <ShopInfo>(); if (info == null) { throw new ArgumentNullException("更新门店,参数不能为空"); } IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>(); IDishCache dishservice = ServiceObjectContainer.Get <IDishCache>(); info.UpdateDate = DateTime.Now; //更新门店信息 cannext = DBConnectionManager.Instance.Writer.Update(new ShopUpdateSpefication(info).Satifasy()); //门店信息更新成功,更新关联食物的门店名称 if (cannext) { cannext = false; cannext = DBConnectionManager.Instance.Writer.Update(new DishShopNameUpdateSpefication(info.ShopId, info.ShopName).Satifasy()); } result.Status = cannext; if (!cannext) { DBConnectionManager.Instance.Writer.Rollback(); result.Message = "更新门店失败,请确认参数合法"; } else { DBConnectionManager.Instance.Writer.Commit(); //同步缓存 shopservice.SaveInfo(info); dishservice.UpdateDishInfoByChangeShopName(shopInfo.ShopId, shopInfo.ShopName); } } catch (Exception ex) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = "更新门店出错:" + ex.Message; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:UpdateShopInfo() .ShopService"), LogType.ErrorLog); } return(result); }
public JsonResult GenerateShop(Shop shop) { IShopService shopservice = ServiceObjectContainer.Get <IShopService>(); shop.ShopId = Generation.GenerationId(); shop.UpdateDate = DateTime.Now; Result result = shopservice.CreatShopInfo(shop); return(Json(result)); }
public JsonResult ShakeNearShop(ShakeParam param) { param.NearDistance = base.SearchDistance; //存放当前定位 HttpContext.Session["Position"] = string.Format("{0},{1}", param.Longitude, param.Latitude); //筛选附近店铺 Result <IList <Shop> > shoplist = ServiceObjectContainer.Get <IShakeService>().ShakeNearShops(param); return(Json(shoplist, JsonRequestBehavior.AllowGet)); }
public JsonResult ForgetSubmit(string mail) { Result result = new Result() { Status = false, }; //生成验证码发送到邮箱 加入缓存 result.Status = ServiceObjectContainer.Get <IAccountService>().SendForgetVerificationCode(mail).Status; return(Json(result)); }
/// <summary> /// 根据食谱编号移除整个食谱信息 /// </summary> /// <param name="recipesId"></param> /// <param name="phone"></param> /// <returns></returns> public Result RemoveRecipesById(int recipesId, long phone) { Result result = new Result() { Status = true, Message = "删除食谱成功" }; try { if (recipesId == 0) { throw new ArgumentNullException("删除食谱,参数非法"); } //食谱缓存服务 IRecipesCache recipesservice = ServiceObjectContainer.Get <IRecipesCache>(); IRelationShareInfoCache relationservice = ServiceObjectContainer.Get <IRelationShareInfoCache>(); //删除食谱绑定关系 bool cannext = false; cannext = DBConnectionManager.Instance.Writer.Update(new RelationShareDeleteSpefication(recipesId.ToString(), phone, 0).Satifasy()); if (cannext) { cannext = false; //修改食谱信息为禁用 cannext = DBConnectionManager.Instance.Writer.Update(new RecipesDeleteSpefication(recipesId.ToString(), 0).Satifasy()); } if (!cannext) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = "删除食谱失败,请确保请求数据合法"; } else { DBConnectionManager.Instance.Writer.Commit(); relationservice.RemoveRelationShareByRecipes(recipesId, phone); recipesservice.SetRecipesEnable(recipesId, false); } } catch (Exception ex) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = "删除食谱出错:" + ex.Message; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:RemoveRecipesById() .RecipesService"), LogType.ErrorLog); } return(result); }
public JsonResult ResetPassword(string mail, string code) { Result result = new Result() { Status = false, Message = "密码修改失败", StatusCode = "RP000" }; result = ServiceObjectContainer.Get <IAccountService>().ResetPassword(mail, code, 0); return(Json(result)); }
public JsonResult ForgetVerivicationCode(string mail, string code) { Result result = new Result() { Status = false, Message = "验证码不正确", StatusCode = "FV000" }; result = ServiceObjectContainer.Get <IAccountService>().VerificationForgetCode(mail, code); return(Json(result)); }
public JsonResult GetShopPageList(int pageindex) { IShopService shops = ServiceObjectContainer.Get <IShopService>(); PageSearchParam param = new PageSearchParam(); param.PageNumer = 3; param.SearchType = 0; param.PageIndex = pageindex; return(Json(shops.GetShopPageList(param))); }
public ActionResult DishView(int dishId) { ViewBag.Account = base.CurrentAccount; //获取单品信息 Result <Dish> dishinfo = ServiceObjectContainer.Get <IDishService>().SearchDishInfoById(dishId); //获取其他包含此单品的食谱 Result <IList <Recipes> > recipes = ServiceObjectContainer.Get <IRecipesService>().GetSomeRecpiesByDishId(dishId, 8); ViewBag.Recipes = recipes.Data; return(View(dishinfo.Data)); }
public ActionResult RequireRegist(string phone, string code) { string codesave = CookieUtils.Get(string.Format("code{0}", phone)); if (!string.IsNullOrEmpty(codesave)) { if (code == codesave) { ServiceObjectContainer.Get <IAccountService>().RequireAccount(Int64.Parse(phone)); } } return(Redirect(Url.Action("Index", "Home"))); }
public JsonResult AddStore() { IShopService shop = ServiceObjectContainer.Get <IShopService>(); Shop shopmodel = new Shop(); shopmodel.ShopId = Generation.GenerationId(); shopmodel.UpdateDate = DateTime.Now; shopmodel.ShopName = "成都人民南路四段门店"; shopmodel.Description = "测试门店"; shopmodel.Longitude = 104.073773; shopmodel.Latitude = 30.638901; return(Json(shop.CreatShopInfo(shopmodel))); }
/// <summary> /// 根据食谱编号获取包含此食谱单品的相似食谱集 /// </summary> /// <param name="recipeId">获取食谱编号</param> /// <param name="num">获取食谱集数量</param> /// <returns></returns> public Result <IList <Recipes> > GetSomeRecpiesByRecipeId(int recipeId, int num) { Result <IList <Recipes> > result = new Result <IList <Recipes> >() { Status = true, Data = new List <Recipes>(), Message = "成功获取相似的食谱集" }; if (recipeId == 0 || num == 0) { result.Status = false; result.Message = "获取食谱失败,请检查参数合法性"; return(result); } try { //获取食谱的单品 IList <RelationShareInfo> recipesshare = ServiceObjectContainer.Get <IRelationShareInfoCache>().GetRelationShareByReceipId(recipeId).ToList(); if (recipesshare != null && recipesshare.Count > 0) { IList <int> dishids = new List <int>(); foreach (RelationShareInfo shareitem in recipesshare) { dishids.Add(shareitem.DishId); } //获取包含单品编号的其他的关系集合 IList <RelationShareInfo> shareinfo = ServiceObjectContainer.Get <IRelationShareInfoCache>().GetRelationShareByDishId(dishids).Where(i => i.RecipesId != recipeId).OrderByDescending(t => t.UpdateDate).Take(num).ToList(); if (shareinfo != null && shareinfo.Count > 0) { //获取食谱集合信息 foreach (var item in shareinfo) { Recipes recipe = ServiceObjectContainer.Get <IRecipesCache>().GetRecipesInfoById(item.RecipesId).Copy <Recipes>(); result.Data.Add(recipe); } } } } catch (Exception ex) { result.Status = false; result.Message = "获取食谱集异常:" + ex.Message; result.StatusCode = "6000001"; } return(result); }
public JsonResult CheckMail(string mail) { Result registresult = new Result() { Status = true, Message = "邮箱已被注册", StatusCode = "CM000" }; if (!string.IsNullOrEmpty(mail)) { registresult.Status = ServiceObjectContainer.Get <IAccountService>().CheckMailRegisted(mail).Status; } return(Json(registresult)); }
public JsonResult CheckPhone(string phone) { Result registresult = new Result() { Status = true, Message = "手机已被注册", StatusCode = "CP000" }; if (!string.IsNullOrEmpty(phone)) { registresult.Status = ServiceObjectContainer.Get <IAccountService>().CheckPhoneRegisted(phone).Status; } return(Json(registresult)); }
public JsonResult AddRecipes() { IRecipesService recipes = ServiceObjectContainer.Get <IRecipesService>(); Recipes recipesmodel = new Recipes(); recipesmodel.RecipesId = Generation.GenerationId(); recipesmodel.Name = "清淡的"; recipesmodel.IsPrivate = false; recipesmodel.Phone = 18502850589; recipesmodel.Description = "测试食谱"; recipesmodel.UpdateDate = DateTime.Now; return(Json(recipes.CreatRecipes(recipesmodel))); }
public Result <IList <Dish> > GetFavoriteDishByPhone(long phone) { Result <IList <Dish> > result = new Result <IList <Dish> >() { Status = true, Message = "查找单品集合成功" }; try { //收藏关系缓存 IRelationFavoriteCache favoritecache = ServiceObjectContainer.Get <IRelationFavoriteCache>(); //食谱缓存服务 IDishCache dishcache = ServiceObjectContainer.Get <IDishCache>(); if (phone == 0) { throw new ArgumentException("获取食谱,参数非法"); } //获取收藏关系 IList <FavoriteInfo> favoritelist = favoritecache.GetFavoriteByPhone(phone, Model.Enum.FavoriteTypeEnum.收藏单品); IList <int> favoriterecipesId = favoritelist.Select(s => s.FavoriteId).ToList(); //获取单品信息 IList <DishInfo> favoritedishs = dishcache.GetDishInfoById(favoriterecipesId); if (favoritedishs != null && favoritedishs.Count > 0) { result.Data = favoritedishs.CopyList <DishInfo, Dish>(); result.Status = true; } else { result.Status = false; result.Data = new List <Dish>(); } } catch (Exception ex) { result.Status = false; result.Data = new List <Dish>(); result.Message = "查找单品出错:" + ex.Message; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:GetFavoriteDishByPhone() .DishService"), LogType.ErrorLog); } return(result); }
public JsonResult LoginRequest(LoginRequest account) { Result <Account> loginresult = new Result <Account>() { Status = true, Message = "", StatusCode = "", Data = null }; string lastdate = CookieUtils.Get("lastSubmit"); if (string.IsNullOrEmpty(lastdate)) { CookieUtils.SetCookie("lastSubmit", DateTime.Now.ToString()); } else { DateTime now = DateTime.Now; CookieUtils.SetCookie("lastSubmit", now.ToString()); double seconds = now.Subtract(Convert.ToDateTime(lastdate)).TotalMilliseconds; if (seconds < 1000 * 5) { loginresult.Status = false; loginresult.Message = "操作过于频繁,请稍后再试"; loginresult.StatusCode = "LG000"; } } //数据验证 if (loginresult.Status) { loginresult = VerificationAccount(account.LoginUsername, account.LoginSecurity); } //登录操作 if (loginresult.Status) { loginresult = ServiceObjectContainer.Get <IAccountService>().SignIn(account.LoginUsername, account.LoginSecurity); if (loginresult.Status) { HttpContext.Session["CurrentAccount"] = loginresult.Data.Phone; } } return(Json(loginresult)); }
/// <summary> /// 更新食谱信息 /// </summary> /// <param name="recipes"></param> /// <returns></returns> public Result UpdateRecipes(Recipes recipes) { Result result = new Result() { Status = true, Message = "删除食谱成功" }; try { //食谱缓存服务 IRecipesCache recipesservice = ServiceObjectContainer.Get <IRecipesCache>(); RecipesInfo info = recipes.Copy <RecipesInfo>(); if (info == null) { throw new ArgumentNullException("更新食谱,参数非法"); } info.UpdateDate = DateTime.Now; result.Status = DBConnectionManager.Instance.Writer.Update(new RecipesUpdateSpefication(info).Satifasy()); if (!result.Status) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = "更新食谱失败,请确保请求数据合法"; } else { DBConnectionManager.Instance.Writer.Commit(); //更新缓存 recipesservice.SaveInfo(info); } } catch (Exception ex) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = "删除食谱出错:" + ex.Message; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:UpdateRecipes() .RecipesService"), LogType.ErrorLog); } return(result); }