示例#1
0
        public ActionResult DeleteSurvey(long id, FormCollection collection)
        {
            try
            {
                SurveyFactory DeleteSurvey = new SurveyFactory();
                SurveyEntity  Survey       = new SurveyEntity();
                Survey = DeleteSurvey.GetSurveyById(id);

                DataLayer.tblSurvey NewSurvey = new DataLayer.tblSurvey();
                NewSurvey.SurveyId          = id;
                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       = Survey.CreatedDate;
                NewSurvey.CreatedBy         = Survey.CreatedBy;
                NewSurvey.UpdatedDate       = DateTime.Now;
                NewSurvey.UpdatedBy         = null;
                NewSurvey.IsActive          = false; // IsActive will be false in delete record

                DeleteSurvey.SaveSurvey(NewSurvey);

                return(RedirectToAction("Survey"));
            }
            catch
            {
                return(View());
            }
        }
示例#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();
     }
 }