Exemple #1
0
        public ActionResult Create([Bind(Exclude = "Technology")] TechnologyContent technologyContent)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    technologyContent.Description           = HttpContext.Server.HtmlEncode(technologyContent.Description);
                    technologyContent.Example               = HttpContext.Server.HtmlEncode(technologyContent.Example);
                    technologyContent.IsActive              = true;
                    technologyContent.TechnologyContentGuid = Guid.NewGuid();
                    technologyContent.SeqNo = db.TechnologyContent.Count(x => x.TechnologyGuid == technologyContent.TechnologyGuid) + 1;
                    db.TechnologyContent.Add(technologyContent);
                    db.SaveChanges();
                    return(RedirectToAction("Details", "Technology", new { id = technologyContent.TechnologyContentGuid }));
                }

                ViewBag.TechnologyGuid = new SelectList(db.Technologies.AsNoTracking(), "TechnologyGuid", "TechnologyName", technologyContent.TechnologyGuid);
                return(View(technologyContent));
            }
            catch (Exception ex)
            {
                log.Error("TechnologyContentController  Create- post Action : " + ex.Message);
                return(RedirectToAction("Index", "Error", new { exception = ex }));
            }
        }
Exemple #2
0
        public ActionResult LikeContent(bool like, Guid contentGuid)
        {
            TechnologyContent technologyContent = db.TechnologyContent.Find(contentGuid);

            //db.TechnologyContent.Remove(technologyContent);
            //db.SaveChanges();
            return(this.Json(true, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     try
     {
         TechnologyContent technologyContent = db.TechnologyContent.Find(id);
         technologyContent.IsActive = false;
         // db.TechnologyContent.Remove(technologyContent);
         db.SaveChanges();
         var guid = db.TechnologyContent.FirstOrDefault(x => x.TechnologyGuid == technologyContent.TechnologyGuid && x.IsActive) == null ? new Guid()
             : db.TechnologyContent.FirstOrDefault(x => x.TechnologyGuid == technologyContent.TechnologyGuid && x.IsActive).TechnologyContentGuid;
         return(RedirectToAction("Details", "Technology", new { id = guid }));
     }
     catch (Exception ex)
     {
         log.Error("TechnologyContentController  Delete- Post Action : " + ex.Message);
         return(RedirectToAction("Index", "Error", new { exception = ex }));
     }
 }
Exemple #4
0
 public ActionResult Edit([Bind(Exclude = "Technology")] TechnologyContent technologyContent)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(technologyContent).State = EntityState.Modified;
             technologyContent.Description     = HttpContext.Server.HtmlEncode(technologyContent.Description);
             technologyContent.Example         = HttpContext.Server.HtmlEncode(technologyContent.Example);
             db.SaveChanges();
             return(RedirectToAction("Details", "Technology", new { id = technologyContent.TechnologyContentGuid }));
         }
         ViewBag.TechnologyGuid = new SelectList(db.Technologies.AsNoTracking(), "TechnologyGuid", "TechnologyName", technologyContent.TechnologyGuid);
         return(View(technologyContent));
     }
     catch (Exception ex)
     {
         log.Error("TechnologyContentController  Edit- Post Action : " + ex.Message);
         return(RedirectToAction("Index", "Error", new { exception = ex }));
     }
 }