/// <summary> /// 新增或修改渠道类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //修改渠道类型,首先获取渠道类型数据 int id; if (int.TryParse(Request.QueryString["id"], out id)) { ViewState["channelType"] = new ChannelTypeBll().GetEntityById(id); } } else { //将渠道类型新增或修改的数据保存到数据库 var entity = new ChannelTypeEntity() { ID = Request.Form["ID"] == null ? 0 : int.Parse(Request.Form["ID"]), Name = Request.Form["Name"] }; new ChannelTypeBll().UpdateOrInsertEntity(entity); //回到渠道类型列表页面 Response.Redirect("ChannelTypeList.aspx"); Response.End(); } }
/// <summary> /// 根据ID获取渠道类型 /// </summary> /// <param name="id">渠道类型ID</param> /// <returns></returns> public ChannelTypeEntity GetEntityById(int id) { var entity = new ChannelTypeDll().LoadEntity(p => p.ID == id); var viewEntity = new ChannelTypeEntity(); return(viewEntity.GetViewModel(entity)); }
/// <summary> /// 获取渠道类型列表 /// </summary> /// <returns></returns> public List <ChannelTypeEntity> GetEntities() { var entities = new ChannelTypeDll().LoadEntities(p => p.ID > 0).ToList(); var viewEntity = new ChannelTypeEntity(); return(entities.Select(p => viewEntity.GetViewModel(p)).ToList()); }
/// <summary>Creates a new, empty ChannelTypeEntity object.</summary> /// <returns>A new, empty ChannelTypeEntity object.</returns> public override IEntity Create() { IEntity toReturn = new ChannelTypeEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewChannelType // __LLBLGENPRO_USER_CODE_REGION_END return(toReturn); }
public ActionResult DeleteConfirmed(int id) { ChannelTypeEntity channelTypeEntity = channelTypeService.GetById(id); channelTypeEntity.IsDeleted = true; channelTypeEntity.UpdatedByID = User.Identity.GetUserId(); channelTypeEntity.UpdatedDate = DateTime.Now; channelTypeService.Save(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,Name,CreatedDate,UpdatedDate,IsActive,IsDeleted,CreatedByID,UpdatedByID")] ChannelTypeEntity channelTypeEntity) { if (ModelState.IsValid) { channelTypeEntity.CreatedByID = User.Identity.GetUserId(); channelTypeService.Add(channelTypeEntity); channelTypeService.Save(); return(RedirectToAction("Index")); } return(View(channelTypeEntity)); }
/// <summary> /// 添加或修改渠道类型 /// </summary> /// <param name="viewEntity">渠道类型实体</param> /// <returns></returns> public bool UpdateOrInsertEntity(ChannelTypeEntity viewEntity) { var entity = viewEntity.GetDataEntity(viewEntity); if (entity.ID > 0) { return new ChannelTypeDll().UpdateEntity(entity); } else { return new ChannelTypeDll().AddEntity(entity).ID > 0; } }
/// <summary> /// 添加或修改渠道类型 /// </summary> /// <param name="viewEntity">渠道类型实体</param> /// <returns></returns> public bool UpdateOrInsertEntity(ChannelTypeEntity viewEntity) { var entity = viewEntity.GetDataEntity(viewEntity); if (entity.ID > 0) { return(new ChannelTypeDll().UpdateEntity(entity)); } else { return(new ChannelTypeDll().AddEntity(entity).ID > 0); } }
// GET: City/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChannelTypeEntity channelTypeEntity = channelTypeService.GetById(id); if (channelTypeEntity == null) { return(HttpNotFound()); } return(View(channelTypeEntity)); }
public ActionResult Edit([Bind(Include = "ID,Name,CreatedDate,UpdatedDate,IsActive,IsDeleted,CreatedByID,UpdatedByID")] ChannelTypeEntity channelTypeEntity) { if (ModelState.IsValid) { // channelTypeService.Entry(channelTypeEntity).State = EntityState.Modified; ChannelTypeEntity channelTypeEntityOLD = channelTypeService.GetById(channelTypeEntity.ID); channelTypeEntityOLD.UpdatedByID = User.Identity.GetUserId(); channelTypeEntityOLD.UpdatedDate = DateTime.Now; channelTypeEntityOLD.IsActive = channelTypeEntity.IsActive; channelTypeEntityOLD.Name = channelTypeEntity.Name; channelTypeService.Update(channelTypeEntityOLD); channelTypeService.Save(); return(RedirectToAction("Index")); } return(View(channelTypeEntity)); }
// POST: City/Active/5 public ActionResult Active(int id) { ChannelTypeEntity channelTypeEntity = channelTypeService.GetById(id); if (channelTypeEntity.IsActive == true) { channelTypeEntity.IsActive = false; } else { channelTypeEntity.IsActive = true; } channelTypeService.Save(); return(RedirectToAction("Index")); }
/// <summary> /// 根据ID获取渠道类型 /// </summary> /// <param name="id">渠道类型ID</param> /// <returns></returns> public ChannelTypeEntity GetEntityById(int id) { var entity = new ChannelTypeDll().LoadEntity(p => p.ID == id); var viewEntity = new ChannelTypeEntity(); return viewEntity.GetViewModel(entity); }
/// <summary> /// 获取渠道类型列表 /// </summary> /// <returns></returns> public List<ChannelTypeEntity> GetEntities() { var entities = new ChannelTypeDll().LoadEntities(p => p.ID > 0).ToList(); var viewEntity = new ChannelTypeEntity(); return entities.Select(p => viewEntity.GetViewModel(p)).ToList(); }