Example #1
0
        private CateGoryEntity GetEntity()
        {
            CateGoryEntity model = CateGoryFactory.CreateCateGoryEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());

            model.Title = txtTitle.Text;
            return(model);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest Request = context.Request;

            context.Response.ContentType = "application/json";

            string action   = context.Request.Params["action"].ToLower();
            int    ticketid = 0;
            int    category = 0;

            switch (action)
            {
            case "removefromcategory":
                int.TryParse(Request.Params["ticketid"], out ticketid);
                int.TryParse(Request.Params["cagetory"], out category);
                bool result = ccApp.RemoveTicketFromCateGory(ticketid, category);
                context.Response.Write(result.ToString().ToLower());
                break;

            case "addtocategory":
                int.TryParse(Request.Params["ticketid"], out ticketid);
                int.TryParse(Request.Params["cagetory"], out category);
                CateGoryTicketEntity model = CateGoryFactory.CreateCateGoryTicketEntity(UserID, ObjectFactory.GetInstance <ISystemDateTime>());
                model.TicketID   = ticketid;
                model.CategoryID = category;
                int id = ccApp.AssignTicketToCateGory(model);
                context.Response.Write(id > 0 ? "true" : "false");
                break;

            default:
                context.Response.Write("[]");
                break;
            }
        }
Example #3
0
        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");
                }
            }
        }