/// <summary> /// 修改电站用户关系 /// </summary> /// <param name="plantUser"></param> /// <returns></returns> public int ModifyPlantUser(PlantUser plantUser) { return _iplantuserdao.Update(plantUser); }
/// <summary> /// 添加电站用户关系对应 /// </summary> /// <param name="plantUser">电站用户关系对应实体</param> /// <returns></returns> public int AddPlantUser(PlantUser plantUser) { return _iplantuserdao.Insert(plantUser); }
/// <summary> /// 根据userID查询电站 /// </summary> /// <param name="plantUser">电站用户关系对应实体</param> /// <returns></returns> public IList<PlantUser> GetAllPlantUserByUserID(PlantUser plantUser) { return _iplantuserdao.GetAllPlantUserByUserID(plantUser); }
/// <summary> /// 根据plantID,userID查询 /// </summary> /// <param name="plantUser">电站用户关系对应实体</param> /// <returns></returns> public PlantUser GetPlantUserByPlantIDUserID(PlantUser plantUser) { return _iplantuserdao.GetPlantUserByPlantIDUserID(plantUser); }
public ActionResult OpenPlant(PlantUser plantUser) { bool exists = false; IList<PlantUser> plantsUser = plantUserService.GetOpenPlant(plantUser.plantID); ViewData["data"] = plantsUser; User user = userservice.GetUserByName(plantUser.username);//查询是否存在该用户 if (user == null) { ModelState.AddModelError("Error", Resources.SunResource.USER_OPENPLANT_DIDNT_FIND); return View(plantUser); } else { User tmpUser; foreach (PlantUser pUser in plantsUser) { tmpUser = UserService.GetInstance().Get(pUser.userID); if (tmpUser.username.Equals(plantUser.username)) { exists = true; break; } } if (exists) { ModelState.AddModelError("Error", "The user has the plant station"); return View(plantUser); } else { plantUser.userID = user.id; plantUserService.AddPlantUser(plantUser); return RedirectToAction("IncludeAllplants", "user"); } } }
public ActionResult OpenPlant(int id) { PlantUser plantUser = new PlantUser(); plantUser.plantID = id; IList<PlantUser> plantsUser = plantUserService.GetOpenPlant(id); ViewData["data"] = plantsUser; return View(plantUser); }
public ActionResult Recommend(int id) { Plant plantInfo = plantService.GetPlantInfoById(id); User user = userService.GetUserByName(UserUtil.demousername); if (user == null) { ViewData["error"] = "示例用户不存在!"; return RedirectToAction(@"plants", "admin"); } PlantUser plantUser = new PlantUser(); plantUser.userID = user.id; plantUser.plantID = id; plantUser.roleId = Cn.Loosoft.Zhisou.SunPower.Domain.Role.ROLE_LOOKER; plantUser.shared = true; PlantUser tmpPlantUser = plantUserService.GetPlantUserByPlantIDUserID(plantUser); plantInfo.example_plant = true;//将电站标记为示例电站 plantService.UpdatePlantInfo(plantInfo); //关系不存在,则建立关系 if (tmpPlantUser == null) { plantUserService.AddPlantUser(plantUser); //清理缓存,测试版不知道是不是这个原因引起的 CacheService.GetInstance().flushCaches(); tmpPlantUser = plantUserService.GetPlantUserByPlantIDUserID(plantUser); if (tmpPlantUser == null) { ViewData["error"] = "添加示例电站失败!"; } } else ViewData["error"] = "已经是示例电站了!"; return RedirectToAction(@"plants", "admin"); }
public ActionResult Recommend(int id) { Plant plantInfo = plantService.GetPlantInfoById(id); User user = userService.GetUserByName(UserUtil.demousername); PlantUser plantUser = new PlantUser(); plantUser.userID = user.id; plantUser.plantID = id; PlantUser plant = plantUserService.GetPlantUserByPlantIDUserID(plantUser);//判断电站是否是示例电站 if (plant == null) { plantInfo.example_plant = true;//将电站标记为示例电站 plantService.UpdatePlantInfo(plantInfo); plantUserService.AddPlantUser(plantUser); } else ViewData["error"] = "This plant is exampleplant!"; return RedirectToAction(@"plants", "admin"); }
/// <summary> /// 取消示例电站 /// </summary> /// <param name="id">电站id</param> /// <returns></returns> public ActionResult DelRecommend(int id) { Plant plantInfo = plantService.GetPlantInfoById(id); User user = userService.GetUserByName(UserUtil.demousername); PlantUser plantUser = new PlantUser(); plantUser.userID = user.id; plantUser.plantID = id; plantInfo.example_plant = false; plantService.UpdatePlantInfo(plantInfo); plantUserService.ClosePlant(id, user.id); return RedirectToAction(@"plants", "admin"); }