public ActionResult DeleteChannel(long id)
        {
            try
            {
                ChannelFactory DeleteChannel = new ChannelFactory();
                ChannelEntity  Channel       = new ChannelEntity();
                Channel = DeleteChannel.GetChannelById(id);

                DataLayer.tblChannel NewChannel = new DataLayer.tblChannel();
                NewChannel.ChannelId = id;

                NewChannel.ChannelName = Channel.ChannelName;
                NewChannel.CreatedDate = Channel.CreatedDate;
                NewChannel.CreatedBy   = Channel.CreatedBy;
                NewChannel.UpdatedDate = DateTime.Now;
                NewChannel.UpdatedBy   = null;
                NewChannel.IsActive    = false; // IsActive will be false in delete record

                DeleteChannel.SaveChannel(NewChannel);

                return(RedirectToAction("Channel"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #2
0
 public ActionResult CreateSurvey(SurveyEntity Survey)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ValidationFactory    VF         = new ValidationFactory();
             SurveyFactory        AddSurvey  = new SurveyFactory();
             DataLayer.tblSurvey  NewSurvey  = new DataLayer.tblSurvey();
             DataLayer.tblChannel NewChannel = new DataLayer.tblChannel();
             string Message = VF.SurveyValidity(Survey.SurveyName, null);
             if (Message != "Success")
             {
                 ModelState.AddModelError("SurveyName", Message);
                 GetSurveyAnswerType();
                 return(View(Survey));
             }
             else
             {
                 NewSurvey.AnsTypeId         = Survey.AnsTypeId;
                 NewSurvey.SurveyName        = Survey.SurveyName;
                 NewSurvey.SurveyDescription = Survey.SurveyDescription;
                 NewSurvey.CompletionText    = Survey.CompletionText;
                 NewSurvey.IsNeverExpire     = Survey.IsNeverExpire;
                 NewSurvey.ExpiryDate        = Survey.ExpiryDate;
                 NewSurvey.CreatedDate       = DateTime.Now;
                 NewSurvey.CreatedBy         = null;
                 NewSurvey.UpdatedDate       = null;
                 NewSurvey.UpdatedBy         = null;
                 NewSurvey.IsActive          = true;
                 AddSurvey.SaveSurvey(NewSurvey);
                 return(RedirectToAction("Survey"));
             }
         }
         else
         {
             GetSurveyAnswerType();
             return(View(Survey));
         }
     }
     catch (Exception Ex)
     {
         GetSurveyAnswerType();
         return(View());
     }
     finally
     {
         GetSurveyAnswerType();
     }
 }
Exemple #3
0
 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();
     }
 }
Exemple #4
0
 public ActionResult CreateBlog(BlogEntity Blog)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ValidationFactory    VF         = new ValidationFactory();
             BlogFactory          AddBlog    = new BlogFactory();
             DataLayer.tblBlog    NewBlog    = new DataLayer.tblBlog();
             DataLayer.tblChannel NewChannel = new DataLayer.tblChannel();
             string Message = VF.BlogValidity(Blog.BlogName, null);
             if (Message != "Success")
             {
                 ModelState.AddModelError("BlogName", Message);
                 GetTopic();
                 return(View(Blog));
             }
             else
             {
                 NewBlog.BlogName    = Blog.BlogName;
                 NewBlog.BlogHeading = Blog.BlogHeading;
                 NewBlog.TopicId     = Blog.TopicId;
                 NewBlog.CreatedDate = DateTime.Now;
                 NewBlog.CreatedBy   = null;
                 NewBlog.UpdatedDate = null;
                 NewBlog.UpdatedBy   = null;
                 NewBlog.IsActive    = true;
                 AddBlog.SaveBlog(NewBlog);
                 return(RedirectToAction("Blog"));
             }
         }
         else
         {
             GetTopic();
             return(View(Blog));
         }
     }
     catch (Exception Ex)
     {
         GetTopic();
         return(View());
     }
     finally { GetTopic(); }
 }
        public ActionResult EditChannel(int id, ChannelEntity Channel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ChannelFactory       EditChannel = new ChannelFactory();
                    DataLayer.tblChannel NewChannel  = new DataLayer.tblChannel();

                    ValidationFactory VF      = new ValidationFactory();
                    string            Message = VF.ChannelValidity(Channel.ChannelName, id);
                    if (Message != "Success")
                    {
                        ModelState.AddModelError("ChannelName", Message);
                        return(View(Channel));
                    }
                    else
                    {
                        NewChannel.ChannelId   = id;
                        NewChannel.ChannelName = Channel.ChannelName;
                        NewChannel.CreatedDate = Channel.CreatedDate;
                        NewChannel.CreatedBy   = null;
                        NewChannel.UpdatedDate = DateTime.Now;
                        NewChannel.UpdatedBy   = null;
                        NewChannel.IsActive    = Channel.IsActive;
                        EditChannel.SaveChannel(NewChannel);
                        return(RedirectToAction("Channel"));
                    }
                }
                else
                {
                    return(View(Channel));
                }
            }
            catch
            {
                return(View());
            }
        }