Beispiel #1
0
        public ActionResult Detail(int id)
        {
            TOURIS_TV_CATEGORY categoryView = new TOURIS_TV_CATEGORY();
            TOURIS_TV_CATEGORY categoryRes  = new TOURIS_TV_CATEGORY();

            categoryView.ID = id;

            categoryRes = JsonConvert.DeserializeObject <TOURIS_TV_CATEGORY>(ParsingObject.RequestData(id, "Category", "RetrieveData", EnumList.IHttpMethod.Put.ToString()));
            return(View(categoryRes));
        }
Beispiel #2
0
        public IHttpActionResult RetrieveData(int id)
        {
            ApiResData res = new ApiResData();

            try
            {
                TOURIS_TM_CATEGORY category     = repo.Retrieve(id);
                TOURIS_TV_CATEGORY categoryView = new TOURIS_TV_CATEGORY();

                if (category != null)
                {
                    categoryView.ID                   = category.ID;
                    categoryView.CATEGORY_CODE        = category.CATEGORY_CODE;
                    categoryView.CATEGORY_NAME        = category.CATEGORY_NAME;
                    categoryView.CATEGORY_DESCRIPTION = category.CATEGORY_DESCRIPTION;
                    categoryView.URL                  = category.URL;
                    categoryView.CLASS                = category.CLASS;
                    categoryView.PHOTO_PATH           = category.PHOTO_PATH;
                    categoryView.CREATED_BY           = category.CREATED_BY;
                    categoryView.CREATED_TIME         = category.CREATED_TIME;
                    categoryView.LAST_MODIFIED_BY     = category.LAST_MODIFIED_BY;
                    categoryView.LAST_MODIFIED_TIME   = category.LAST_MODIFIED_TIME;

                    if (category.TOURIS_TM_SUB_CATEGORY.Count > 0)
                    {
                        foreach (var item in category.TOURIS_TM_SUB_CATEGORY)
                        {
                            TOURIS_TV_SUB_CATEGORY subCategory = new TOURIS_TV_SUB_CATEGORY();
                            subCategory.ID          = item.ID;
                            subCategory.ADDRESS     = item.ADDRESS;
                            subCategory.CATEGORY_ID = item.CATEGORY_ID;
                            subCategory.END_TIME    = item.END_TIME;
                            subCategory.START_TIME  = item.START_TIME;
                            subCategory.SUB_CATEGORY_DESCRIPTION = item.SUB_CATEGORY_DESCRIPTION;
                            subCategory.SUB_CATEGORY_NAME        = item.SUB_CATEGORY_NAME;
                            subCategory.VILLAGE_ID = item.VILLAGE_ID;
                            subCategory.PHOTO_PATH = item.PHOTO_PATH;

                            categoryView.TOURIS_TV_SUB_CATEGORY.Add(subCategory);
                        }
                    }

                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { categoryView }, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
Beispiel #3
0
        public static SelectList GetCategoryList()
        {
            List <TOURIS_TV_CATEGORY> categories = JsonConvert.DeserializeObject <List <TOURIS_TV_CATEGORY> >(ParsingObject.RequestData(null, "Category", "GridBind", EnumList.IHttpMethod.Get.ToString()));
            TOURIS_TV_CATEGORY        category   = new TOURIS_TV_CATEGORY {
                ID = 0, CATEGORY_NAME = "Select Category :"
            };

            categories.Add(category);
            var categoryList = categories.OrderBy(x => x.ID);

            SelectList selectList = new SelectList(categoryList, "ID", "CATEGORY_NAME");

            return(selectList);
        }
Beispiel #4
0
        public IHttpActionResult Add(TOURIS_TV_CATEGORY categoryView)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_CATEGORY category = new TOURIS_TM_CATEGORY();
                category.CATEGORY_CODE        = categoryView.CATEGORY_CODE;
                category.CATEGORY_NAME        = categoryView.CATEGORY_NAME;
                category.CATEGORY_DESCRIPTION = categoryView.CATEGORY_DESCRIPTION;
                category.URL          = categoryView.URL;
                category.CLASS        = categoryView.CLASS;
                category.PHOTO_PATH   = categoryView.PHOTO_PATH;
                category.CREATED_BY   = categoryView.CREATED_BY;
                category.CREATED_TIME = categoryView.CREATED_TIME;
                category.ROW_STATUS   = eStat.fg.IsActive;

                rs = repo.Add(category);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
Beispiel #5
0
        public ActionResult ActionCreate(TOURIS_TV_CATEGORY categoryView, HttpPostedFileBase postedFile)
        {
            try
            {
                string physicalPath = "";
                if (postedFile != null)
                {
                    string ImageName = System.IO.Path.GetFileName(postedFile.FileName); //file2 to store path and url
                    physicalPath = Server.MapPath("~" + Common.GetPathFolderImg() + ImageName);

                    categoryView.PHOTO_PATH = Common.GetPathFolderImg() + ImageName;
                }

                categoryView.CREATED_BY   = CurrentUser.GetCurrentUserId();
                categoryView.CREATED_TIME = CurrentUser.GetCurrentDateTime();

                rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(categoryView, "Category", "Add", EnumList.IHttpMethod.Post.ToString()));
                if (rs.IsSuccess)
                {
                    if (physicalPath != "")
                    {
                        postedFile.SaveAs(physicalPath);
                    }

                    rs.SetSuccessStatus("Data has been created successfully");
                    TempData["msgSuccess"] = rs.MessageText;
                }
                else
                {
                    rs.SetErrorStatus("Data failed to created");
                    TempData["msgError"] = rs.MessageText;
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                rs.SetErrorStatus("Data failed to created");
                TempData["msgError"] = rs.MessageText;
            }

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public IHttpActionResult GridBind()
        {
            ApiResData res = new ApiResData();

            try
            {
                List <TOURIS_TM_CATEGORY> categories    = repo.GridBind();
                List <TOURIS_TV_CATEGORY> categoryViews = new List <TOURIS_TV_CATEGORY>();

                if (categories.Count > 0)
                {
                    foreach (var item in categories)
                    {
                        TOURIS_TV_CATEGORY categoryView = new TOURIS_TV_CATEGORY();
                        categoryView.ID                   = item.ID;
                        categoryView.CATEGORY_CODE        = item.CATEGORY_CODE;
                        categoryView.CATEGORY_NAME        = item.CATEGORY_NAME;
                        categoryView.CATEGORY_DESCRIPTION = item.CATEGORY_DESCRIPTION;
                        categoryView.URL                  = item.URL;
                        categoryView.CLASS                = item.CLASS;
                        categoryView.PHOTO_PATH           = item.PHOTO_PATH;
                        categoryView.CREATED_BY           = item.CREATED_BY;
                        categoryView.CREATED_TIME         = item.CREATED_TIME;
                        categoryView.LAST_MODIFIED_BY     = item.LAST_MODIFIED_BY;
                        categoryView.LAST_MODIFIED_TIME   = item.LAST_MODIFIED_TIME;

                        categoryViews.Add(categoryView);
                    }
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { categoryViews }, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }