Exemple #1
0
        public ActionResult Create(tbl_Url myUrl)
        {
            try
            {
                myUrl.IsApproved = "P";
                //return email address which will be used to find the user id
                myUrl.UserId = objBs.userBs.GetAll().Where(x => x.UserEmail == User.Identity.Name).FirstOrDefault().UserId;

                if (ModelState.IsValid)
                {

                    objBs.urlBs.Insert(myUrl);
                    TempData["Msg"] = "Created Successfully";
                    return RedirectToAction("Index");
                }
                else
                {
                    ViewBag.CategoryId = new SelectList(objBs.categoryBs.GetAll().ToList(), "CategoryId", "CategoryName");
                    return View("Index");
                }
            }
            catch (Exception e1)
            {
                TempData["Msg"] = "Create Failed : " + e1.Message;
                return RedirectToAction("Index");
            }
        }
        public ActionResult Create(tbl_Url url)
        {
            try
            {
                // set default to 'P'ending
                url.c_IsApproved = "P";
                // get user id from this session current authenticated user
                url.i_UserId = _objBl.userBl.GetAll().FirstOrDefault(x => x.c_UserEmail == User.Identity.Name).i_UserId;

                if (ModelState.IsValid)
                {
                    _objBl.urlBl.Insert(url);
                    TempData["Msg"] = "Created Successfully!";
                    return RedirectToAction("Index");
                }
                else
                {
                    ViewBag.CategoryId = new SelectList(_objBl.categoryBl.GetAll().ToList(), "i_CategoryId", "c_CategoryName");
                    ViewBag.UserId = new SelectList(_objBl.userBl.GetAll().ToList(), "i_UserId", "c_UserEmail");
                    return View("Index");
                }
            }
            catch (Exception e1)
            {
                TempData["Msg"] = "Insertion Fail: " + e1.Message + " Error relate to: " + e1.Source;
                return RedirectToAction("Index");
            }
        }
Exemple #3
0
 public void Update(tbl_Url url)
 {
     db.Entry(url).State = EntityState.Modified;
     db.Configuration.ValidateOnSaveEnabled = false;
     Save();
     db.Configuration.ValidateOnSaveEnabled = true;
 }
        public void Update(tbl_Url url)
        {
            //db.Entry(url).State = EntityState.Modified; //?? why Silently! not working GOOGle it

            db.Entry(url).State = EntityState.Modified;
            db.Configuration.ValidateOnSaveEnabled = false;
            Save();
            db.Configuration.ValidateOnSaveEnabled = true;
        }
Exemple #5
0
        public ActionResult Create(tbl_Url model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.CategoryId = new SelectList(objBs.categoryBs.GetAll().ToList(), "CategoryId", "CategoryName");
                return View("Index");
            }

            try
            {
                model.IsApproved = "P";
                model.UserId = objBs.userBs.GetAll().Where(x => x.UserEmail == User.Identity.Name).FirstOrDefault().UserId;
                objBs.urlBs.Insert(model);
                TempData["Msg"] = "Created Successfully";
            }
            catch (Exception exception)
            {
                TempData["Msg"] = "Create Failed : " + exception.Message;
            }

            return RedirectToAction("Index");
        }
 public ActionResult CreateURL(tbl_Url objUrl)
 {
     LinkHubDbEntities db = new LinkHubDbEntities();
     ViewBag.CategoryId = new SelectList(db.tbl_Category, "CategoryId", "CategoryName");
     return View();
 }
 public void Update(tbl_Url url)
 {
     objDb.Update(url);
 }
 public void Insert(tbl_Url url)
 {
     objDb.Insert(url);
 }
 public void Insert(tbl_Url url)
 {
     db.tbl_Url.Add(url);
     Save();
 }
Exemple #10
0
 public void Update(tbl_Url url)
 {
     db.Entry(url).State = EntityState.Modified;
     Save();
 }