Пример #1
0
        public ActionResult Index()
        {
            ViewBag.msgSuccess = TempData["msgSuccess"];
            ViewBag.msgError   = TempData["msgError"];
            List <SBH_TM_GALERY_FOTO> res = new List <SBH_TM_GALERY_FOTO>();

            if (!(bool)Session["IsSuperAdmin"])
            {
                res = repo.GetGaleryByUserId((int)Session["Id"]);
            }
            else
            {
                res = repo.GridBind();
            }

            List <SBH_TM_GALERY_FOTO> resNew = new List <SBH_TM_GALERY_FOTO>();

            if (res.Count > 0)
            {
                var arry = res.Select(i =>
                                      new { createdBy = i.CREATED_BY, eventTitle = i.SBH_TM_NEWS.TITLE })
                           .Distinct().OrderByDescending(s => s).ToArray();

                foreach (var item in arry)
                {
                    SBH_TM_GALERY_FOTO glr = new SBH_TM_GALERY_FOTO();
                    glr.CREATED_BY  = item.createdBy;
                    glr.DESCRIPTION = item.eventTitle; //use field description to declare event title

                    resNew.Add(glr);
                }
            }

            return(View(resNew));
        }
Пример #2
0
        public ActionResult ActionCreate(SBH_TM_GALERY_FOTO galeryView)
        {
            string a = Request.Form["storeImage"];

            try
            {
                string encodedString = Server.HtmlEncode(galeryView.DESCRIPTION);
                galeryView.DESCRIPTION  = encodedString;
                galeryView.USER_ID      = (int)Session["Id"];
                galeryView.CREATED_BY   = Session["UserId"].ToString();
                galeryView.CREATED_TIME = DateTime.Now;
                List <string> lString = CData.GetListString;

                rs = repo.AddAll(galeryView, lString);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus("Data has been created successfully");
                    TempData["msgSuccess"] = rs.MessageText;
                    CData.CleanDataString();
                }
                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"));
        }
Пример #3
0
        public ActionResult ActionEdit(SBH_TM_GALERY_FOTO galeryView, HttpPostedFileBase postedFile)
        {
            try
            {
                string encodedString = Server.HtmlEncode(galeryView.DESCRIPTION);
                galeryView.DESCRIPTION = encodedString;

                galeryView.LAST_MODIFIED_BY   = Session["UserId"].ToString();
                galeryView.LAST_MODIFIED_TIME = DateTime.Now;

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

            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Detail(int id)
        {
            SBH_TM_GALERY_FOTO res = new SBH_TM_GALERY_FOTO();

            res = repo.Retrieve(id);
            return(PartialView(res));
        }
Пример #5
0
        public ResultStatus AddAll(SBH_TM_GALERY_FOTO galery, List <string> listString)
        {
            using (var dbContextTransaction = _ctx.Database.BeginTransaction())
            {
                try
                {
                    foreach (var item in listString)
                    {
                        SBH_TM_GALERY_FOTO galeryNew = galery;
                        galeryNew.PHOTO_PATH = item;
                        _ctx.SBH_TM_GALERY_FOTO.Add(galery);
                        _ctx.SaveChanges();
                    }

                    dbContextTransaction.Commit();
                    rs.SetSuccessStatus();
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    rs.SetErrorStatus(ex.Message);;
                }
            }

            return(rs);
        }
Пример #6
0
        public ActionResult Edit(int id)
        {
            SBH_TM_GALERY_FOTO res = new SBH_TM_GALERY_FOTO();

            ViewBag.GetNewsList = repo.GetNewsList();
            ViewBag.GetUserList = repo.GetUserList();

            res = repo.Retrieve(id);
            return(PartialView(res));
        }
Пример #7
0
        public ResultStatus Add(SBH_TM_GALERY_FOTO galery)
        {
            try
            {
                _ctx.SBH_TM_GALERY_FOTO.Add(galery);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Пример #8
0
        public ResultStatus Delete(int id, string modifiedBy, DateTime modifiedTime)
        {
            try
            {
                SBH_TM_GALERY_FOTO news = _ctx.SBH_TM_GALERY_FOTO.Find(id);
                news.LAST_MODIFIED_TIME = modifiedTime;
                news.LAST_MODIFIED_BY   = modifiedBy;
                news.ROW_STATUS         = eStat.fg.NotActive;

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

            return(rs);
        }
Пример #9
0
        public ResultStatus Edit(SBH_TM_GALERY_FOTO galery)
        {
            try
            {
                SBH_TM_GALERY_FOTO galeryNew = _ctx.SBH_TM_GALERY_FOTO.Find(galery.ID);
                galeryNew.PHOTO_PATH         = galery.PHOTO_PATH;
                galeryNew.DESCRIPTION        = galery.DESCRIPTION;
                galeryNew.NEWS_ID            = galery.NEWS_ID;
                galeryNew.USER_ID            = galery.USER_ID;
                galeryNew.LAST_MODIFIED_TIME = galery.LAST_MODIFIED_TIME;
                galeryNew.LAST_MODIFIED_BY   = galery.LAST_MODIFIED_BY;
                _ctx.Entry(galeryNew).State  = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }