Beispiel #1
0
 public bool Create(Topic pNewTopic)
 {
     try
     {
         _db.Topics.Add(pNewTopic);
         _db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #2
0
        public ActionResult Delete(int id, Topic pNewTopic)
        {
            try
            {
                // TODO: Add delete logic here
                var check = new TopicModel().Delete(id);
                if(check)
                {
                    return RedirectToAction("Index");
                }
                else
                {
                    return View(pNewTopic);
                }

            }
            catch
            {
                return View(pNewTopic);
            }
        }
Beispiel #3
0
 public bool Edits(int pId,Topic pNewTopic)
 {
     try
     {
         var Object = _db.Topics.Find(pId);
         Object.Name = pNewTopic.Name;
         Object.Code = pNewTopic.Code;
         Object.ImageId = pNewTopic.ImageId;
         Object.Descrip = pNewTopic.Descrip;
         Object.OrderDisplay = pNewTopic.OrderDisplay;
         Object.TopicParentID = pNewTopic.TopicParentID;
         Object.EditBy = pNewTopic.EditBy;
         Object.EditDate = pNewTopic.EditDate;
         Object.IsActive = pNewTopic.IsActive;
         Object.LangId = pNewTopic.LangId;
         _db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #4
0
 public ActionResult Create(TopicView pNewTopicView)
 {
     var pNewTopic = new Topic();
     try
     {
         // TODO: Add insert logic here
         pNewTopic.ImageId = pNewTopicView.ImageId;
         pNewTopic.Name = pNewTopicView.Name;
         pNewTopic.Code = pNewTopicView.Code;
         pNewTopic.Descrip = pNewTopicView.Descrip;
         pNewTopic.OrderDisplay = pNewTopicView.OrderDisplay;
         pNewTopic.TopicParentID = new TopicModel().GetIdByName(pNewTopicView.TopicParentID);
         if(pNewTopicView.LangId=="Tiếng Việt")
         {
             pNewTopic.LangId = 0;
         }
         else
         {
             pNewTopic.LangId = 1;
         }
         pNewTopic.CreatedBy = account.Id;
         pNewTopic.CreatedDate = DateTime.Now;
         pNewTopic.EditBy = account.Id;
         pNewTopic.EditDate = DateTime.Now;
         pNewTopic.IsActive = true;
         var check = new TopicModel().Create(pNewTopic);
         if(!check)
         {
             return View(pNewTopicView);
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View(pNewTopicView);
     }
 }