protected void btnDelete_Click(object sender, EventArgs e) { CateGoryEntity model = GetEntity(); if (model == null || model.IsDelete == true) { Response.Redirect(ErrorPageUrl); } if (model.IsProtected || cgApp.DeleteCateGroy(model.GID)) { Redirect(Request.RawUrl, true); } else { ShowFailMessageToClient(cgApp.BrokenRuleMessages); } }
public void ProcessRequest(HttpContext context) { CateGoryApplication ccApp = new CateGoryApplication(); HttpRequest request = context.Request; context.Response.ContentType = "text/plain"; if (IdentityContext.UserID <= 0) { context.Response.Write("[]"); return; } if (string.IsNullOrEmpty(request["type"])) { List <CateGoryEntity> listcategories = ccApp.GetCateGroyListByUserID(UserID); if (listcategories == null || listcategories.Count == 0) { context.Response.Write("[]"); } else { string jsonCategories = UtilFactory.Helpers.JSONHelper.GetJson <List <CateGoryEntity> >(listcategories); context.Response.Write(jsonCategories); } } else { int ticketid = 0; int categoryid = 0; bool checkinput = ( (!string.IsNullOrEmpty(request["ticketid"])) && (!string.IsNullOrEmpty(request["cagetoryid"])) && int.TryParse(request["ticketid"], out ticketid) && int.TryParse(request["cagetoryid"], out categoryid) && ticketid >= 0 && categoryid > 0); if (checkinput) { CateGoryTicketEntity model = CateGoryFactory.CreateCateGoryTicketEntity(UserID, ObjectFactory.GetInstance <ISystemDateTime>()); model.TicketID = ticketid; model.CategoryID = categoryid; switch (request["type"]) { case "addtocategory": int id = ccApp.AssignTicketToCateGory(model); if (id > 0) { context.Response.Write("true"); } else { context.Response.Write("false"); } break; case "removefromcategory": bool result = ccApp.RemoveTicketFromCateGory(ticketid, categoryid); context.Response.Write(result.ToString().ToLower()); break; case "deletecategory": bool result2 = ccApp.DeleteCateGroy(categoryid); context.Response.Write(result2.ToString().ToLower()); break; default: context.Response.Write("null"); break; } } else { context.Response.Write("false"); } } }