Beispiel #1
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);
     }
 }
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 ActionResult Edit(int id)
 {
     var Object = new TopicModel().GetTopicById(id);
     var Result = new TopicView();
     Result.Name = Object.Name;
     Result.Code = Object.Code;
     Result.ImageId = Object.ImageId;
     Result.Descrip = Object.Descrip;
     Result.OrderDisplay = Object.OrderDisplay;
     Result.TopicParentID = new TopicModel().GetNameById(Object.TopicParentID);
     if(Object.LangId==0)
     {
         Result.LangId = "Tiếng Việt";
     }
     else
     {
         Result.LangId = "Tiếng Anh";
     }
     return View(Result);
 }