public ActionResult List(PagerCondition condition) { if (condition == null) { condition = new PagerCondition() { PageSize = 10, PageIndex = 1 }; } Swoopo.Model.JsonResult json = new Swoopo.Model.JsonResult(); try { List<ProductEntity> list = new ProductBLL().getPaged(condition); json.value = list; } catch (BllException e) { #if DEBUG json.error = e.InnerException.Message; #else json.error = e.Message; #endif } catch (DalException ex) { #if DEBUG json.error = ex.InnerException.Message; #else json.error = ex.Message; #endif } return Json(json); }
public ActionResult Signin(FormCollection form) { var returnResult = new Swoopo.Model.JsonResult(); UserEntity userResult; try { var bll = new UserBll(); var user = new UserEntity { UserName = form.Get("UserName"), UserPwd = form.Get("UserPwd"), Email = "*****@*****.**" }; //由于登录时,不需要email,所有用“[email protected]”替代,否则验证无法通过 Validator<UserEntity> userValid = ValidationFactory.CreateValidator<UserEntity>(); ValidationResults r = userValid.Validate(user); if (!r.IsValid) { var list = r.Select(result => result.Message).ToList(); returnResult.error = list; return Json(returnResult); } user.UserPwd = We7Utils.MD5(user.UserPwd); userResult = bll.Signin(user); } catch (BllException ex) { #if DEBUG returnResult.error = ex.InnerException.Message; #else returnResult.error = ex.Message; #endif return Json(returnResult); } catch (DalException dalException) { #if DEBUG returnResult.error = dalException.InnerException.Message; #else returnResult.error = dalException.Message; #endif return Json(returnResult); } if (userResult == null) { //ModelState.AddModelError("", "用户名或密码不正确!"); //return View("Signin"); returnResult.error = "用户名或密码不正确!"; return Json(returnResult); } returnResult.value = true; Session["UserEntity"] = userResult; return Json(returnResult); }
/// <summary> ///插入分类 /// </summary> /// <param name="form"></param> /// <returns></returns> public ActionResult CategoryAction(FormCollection form) { int parentId; string categoryName = string.IsNullOrEmpty(form["CategoryName"]) ? string.Empty : form["CategoryName"].ToString(); int orderId; string remark = form["CategoryName"].ToString(); int.TryParse(string.IsNullOrEmpty(form["ParentID"]) ? string.Empty : form["ParentID"].ToString(), out parentId); int.TryParse(string.IsNullOrEmpty(form["OrderID"]) ? string.Empty : form["OrderID"].ToString(), out orderId); string parentPath = string.Empty; string categoryId = AppCode.Tools.GenericCategoryId(); CategoryBll bll = new CategoryBll(); var returnResult = new Swoopo.Model.JsonResult(); try { if (parentId == 0) { parentPath = categoryId; } else { CategoryEntity parent = new CategoryEntity() { ID = parentId }; parentPath = bll.GetById(parent).Path + "," + categoryId; } CategoryEntity c = new CategoryEntity(); c.CategoryId = categoryId; c.CategoryName = categoryName; c.ParentID = parentId; c.Path = parentPath; c.OrderID = orderId; c.Remark = remark; returnResult.value = bll.Insert(c); } catch (Exception ex) { returnResult.error = ex.Message; } return Json(returnResult); }
public ActionResult Save(ProductEntity product) { Swoopo.Model.JsonResult s = new Swoopo.Model.JsonResult(); try { product.RemainTime = product.EndTime.ToFileTime() - product.StarTime.ToFileTime(); ProductBLL proBll = new ProductBLL(); int result = proBll.Save(product); if (result > 0) { s.value = 1; } else { s.error = "保存失败!"; } } catch (BllException e) { #if DEBUG s.error = e.InnerException.StackTrace; #else s.error = e.Message; #endif } catch (DalException ex) { #if DEBUG s.error = ex.InnerException.StackTrace; #else s.error = ex.Message; #endif } return Json(s); }
/// <summary> /// 分类列表 /// </summary> /// <returns></returns> public System.Web.Mvc.JsonResult CategoryLists() { List<CategoryEntity> list = new CategoryBll().GetAllToTree(); Swoopo.Model.JsonResult json = new Swoopo.Model.JsonResult(); json.value = list; return Json(json); }