public ActionResult DeleteTopic(long id, FormCollection collection) { try { TopicFactory DeleteTopic = new TopicFactory(); TopicEntity Topic = new TopicEntity(); Topic = DeleteTopic.GetTopicById(id); DataLayer.tblTopic NewTopic = new DataLayer.tblTopic(); NewTopic.TopicId = id; NewTopic.ChannelId = Topic.ChannelId; NewTopic.TopicName = Topic.TopicName; NewTopic.CreatedDate = Topic.CreatedDate; NewTopic.CreatedBy = Topic.CreatedBy; NewTopic.UpdatedDate = DateTime.Now; NewTopic.UpdatedBy = null; NewTopic.IsActive = false; // IsActive will be false in delete record DeleteTopic.SaveTopic(NewTopic); return(RedirectToAction("Topic")); } catch { return(View()); } }
public ActionResult AddTopic(TopicEntity Topic) { try { if (ModelState.IsValid) { ValidationFactory VF = new ValidationFactory(); TopicFactory AddTopic = new TopicFactory(); DataLayer.tblTopic NewTopic = new DataLayer.tblTopic(); DataLayer.tblChannel NewChannel = new DataLayer.tblChannel(); string Message = VF.TopicValidity(Topic.TopicName, null); if (Message != "Success") { ModelState.AddModelError("TopicName", Message); GetChannel(); return(View(Topic)); } else { NewTopic.TopicName = Topic.TopicName; NewTopic.ChannelId = Topic.ChannelId; NewTopic.CreatedDate = DateTime.Now; NewTopic.CreatedBy = null; NewTopic.UpdatedDate = null; NewTopic.UpdatedBy = null; NewTopic.IsActive = true; AddTopic.SaveTopic(NewTopic); return(RedirectToAction("Topic")); } } else { GetChannel(); return(View(Topic)); } } catch (Exception Ex) { GetChannel(); return(View()); } finally { GetChannel(); } }
public ActionResult EditTopic(long id, TopicEntity Topic) { try { if (ModelState.IsValid) { TopicFactory EditTopic = new TopicFactory(); DataLayer.tblTopic NewTopic = new DataLayer.tblTopic(); ValidationFactory VF = new ValidationFactory(); string Message = VF.TopicValidity(Topic.TopicName, id); if (Message != "Success") { ModelState.AddModelError("TopicName", Message); GetChannel(); return(View(Topic)); } else { NewTopic.TopicId = id; NewTopic.TopicName = Topic.TopicName; NewTopic.CreatedDate = Topic.CreatedDate; NewTopic.CreatedBy = null; NewTopic.ChannelId = Topic.ChannelId; NewTopic.UpdatedDate = DateTime.Now; NewTopic.UpdatedBy = null; NewTopic.IsActive = Topic.IsActive; EditTopic.SaveTopic(NewTopic); return(RedirectToAction("Topic")); } } else { return(View(Topic)); } } catch { return(View()); } finally { GetChannel(); } }