public ActionResult GetShopByID(int id) { ComResult com = new ComResult(); try { base_shop shop = _service.GetShopByID(id); if (null != shop) { com.DataResult = shop; com.State = 1; return(Json(com)); } else { com.Msg = "获取店铺信息失败!"; com.State = 0; return(Json(com)); } } catch (Exception ex) { com.Msg = ex.ToString(); com.State = 0; return(Json(com)); } }
public ActionResult UpdateShop(base_shop model) { ComResult com = new ComResult(); try { bool isok = _service.UpdateShop(model); if (isok) { com.Msg = "更新成功"; com.State = 1; return(Json(com)); } else { com.Msg = "更新失败"; com.State = 0; return(Json(com)); } } catch (Exception ex) { com.Msg = ex.Message; com.State = 0; return(Json(com)); } }
/// <summary> /// 根据id获取信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public base_shop GetShopByID(int id) { using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { try { base_shop aa = db.Queryable <base_shop>().Where(s => s.shop_id == id).FirstOrDefault(); return(aa); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 更新店铺信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateShop(base_shop model) { using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { try { bool isok = db.Update <base_shop>(new { shop_name = model.shop_name, shop_telephone = model.shop_telephone, shop_zipcode = model.shop_zipcode, shop_address = model.shop_address }, it => it.shop_id == model.shop_id); return(isok); } catch (Exception ex) { throw ex; } } }
public ActionResult Save(base_shop model) { ShopResult com = new ShopResult(); try { com = _service.Save(model); return(Json(com)); } catch (Exception ex) { com.Msg = ex.ToString(); com.success = false; return(Json(com)); } }
/// <summary> /// 修改 添加的方法 /// </summary> /// <param name="model"></param> /// <returns></returns> public ShopResult Save(base_shop model) { bool rstNum = false; ShopResult result = new ShopResult(); using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { #region 判断 if (model == null) { result.success = false; result.Msg = "请填写信息!"; return(result); } if (model.platform_id == 0) { result.success = false; result.Msg = "请选择平台!"; return(result); } if (string.IsNullOrWhiteSpace(model.shop_name)) { result.success = false; result.Msg = "请填写店铺名称!"; return(result); } if (string.IsNullOrWhiteSpace(model.shop_account)) { result.success = false; result.Msg = "请填写管理账号!"; return(result); } if (model.country_id == 0) { result.success = false; result.Msg = "请选择店铺币种!"; return(result); } if (string.IsNullOrWhiteSpace(model.shop_telephone)) { result.success = false; result.Msg = "请填写店铺电话!"; return(result); } if (string.IsNullOrWhiteSpace(model.shop_zipcode)) { result.success = false; result.Msg = "请填写店铺邮编!"; return(result); } if (string.IsNullOrWhiteSpace(model.shop_address)) { result.success = false; result.Msg = "请填写店铺地址!"; return(result); } if (model.platform_lrish == null) { result.success = false; result.Msg = "请填写平台扣点!"; return(result); } #endregion if (model.shop_id > 0) { var list = db.Queryable <base_shop>().InSingle(model.shop_id); if (list == null) { result.success = false; result.Msg = "不存在的店铺信息"; return(result); } if (list.shop_status.Value) { list.shop_status = false; } else { list.shop_status = true; } list.edit_time = DateTime.Now; list.edit_user_id = LoginUser.Current.user_id; rstNum = db.Update <base_shop>(list); } else//添加店铺 { var base_shop = db.Queryable <base_shop>().Where(c => c.del_flag && c.shop_name == model.shop_name).ToList(); if (base_shop.Count > 0) { result.success = false; result.Msg = "已存在的店铺信息,操作失败!"; return(result); } model.create_time = DateTime.Now; model.create_user_id = LoginUser.Current.user_id; model.del_flag = true; model.del_user_id = 0; model.del_time = DateTime.Now; model.edit_time = DateTime.Now; model.edit_user_id = 0; model.remark = model.shop_name; model.settlm_currency = 0; model.shop_status = true; model.LStablename = db.Queryable <base_platform>().Where(s => s.platform_id == model.platform_id).FirstOrDefault().platform_name; var id = db.Insert <base_shop>(model); if (id.ObjToInt() > 0) { rstNum = true; } } if (rstNum) { result.success = true; result.URL = "/Shop/Index"; result.Msg = "操作成功"; return(result); } else { result.success = false; result.Msg = "操作失败"; return(result); } } }