Ejemplo n.º 1
0
        public ActionResult Detail(int id)
        {
            SBH_TM_CATEGORY categoryView = new SBH_TM_CATEGORY();
            SBH_TM_CATEGORY categoryRes  = new SBH_TM_CATEGORY();

            categoryView.ID = id;

            categoryRes = repo.Retrieve(id);
            return(PartialView(categoryRes));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            SBH_TM_CATEGORY categoryView = new SBH_TM_CATEGORY();
            SBH_TM_CATEGORY categoryRes  = new SBH_TM_CATEGORY();

            ViewBag.GetClassButtonList = Dropdown.GetClassButtonList();

            categoryView.ID = id;

            categoryRes = repo.Retrieve(id);
            return(PartialView(categoryRes));
        }
Ejemplo n.º 3
0
        public SelectList GetCategoryList()
        {
            List <SBH_TM_CATEGORY> categories = _ctx.SBH_TM_CATEGORY.Where(x => x.ROW_STATUS == (int)EnumList.RowStatus.Active).ToList();
            SBH_TM_CATEGORY        category   = new SBH_TM_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);
        }
Ejemplo n.º 4
0
        public ResultStatus Add(SBH_TM_CATEGORY category)
        {
            try
            {
                _ctx.SBH_TM_CATEGORY.Add(category);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Ejemplo n.º 5
0
        public ActionResult ActionCreate(SBH_TM_CATEGORY categoryView, HttpPostedFileBase postedFile)
        {
            try
            {
                string encodedString = Server.HtmlEncode(categoryView.DESCRIPTION);
                categoryView.DESCRIPTION = encodedString;
                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.IMAGE_PATH = Common.GetPathFolderImg() + ImageName;
                }

                categoryView.CREATED_BY   = Session["UserId"].ToString();
                categoryView.CREATED_TIME = DateTime.Now;

                rs = repo.Add(categoryView);
                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"));
        }
Ejemplo n.º 6
0
        public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime)
        {
            try
            {
                SBH_TM_CATEGORY category = _ctx.SBH_TM_CATEGORY.Find(id);
                category.LAST_MODIFIED_TIME = modifiedTime;
                category.LAST_MODIFIED_BY   = modifiedBy;
                category.ROW_STATUS         = eStat.fg.NotActive;

                _ctx.Entry(category).State = EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Ejemplo n.º 7
0
        public ResultStatus Edit(SBH_TM_CATEGORY category)
        {
            try
            {
                SBH_TM_CATEGORY categoryNew = _ctx.SBH_TM_CATEGORY.Find(category.ID);
                categoryNew.CATEGORY_NAME      = category.CATEGORY_NAME;
                categoryNew.DESCRIPTION        = category.DESCRIPTION;
                categoryNew.URL                = category.URL;
                categoryNew.CLASS              = category.CLASS;
                categoryNew.IMAGE_PATH         = category.IMAGE_PATH;
                categoryNew.LAST_MODIFIED_TIME = category.LAST_MODIFIED_TIME;
                categoryNew.LAST_MODIFIED_BY   = category.LAST_MODIFIED_BY;
                _ctx.Entry(categoryNew).State  = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }