public BaseViewModel()
 {
     Current = new DRCOG.Domain.Models.Survey.Survey();
     Person = new Person();
 }
        public PartialViewResult CreatePartial(Survey model)
        {
            LoadSessionData();

            CreateProjectViewModel viewModel = _surveyRepository.GetCreateProjectViewModel(model);
            return PartialView("~/Views/Survey/Partials/CreatePartial.ascx", viewModel);
        }
Beispiel #3
0
 public int Add(Survey value)
 {
     return (List.Add(value));
 }
        public CreateProjectViewModel GetCreateProjectViewModel(Survey model)
        {
            List<SqlParameter> improvementTypeParams = new List<SqlParameter>();
            improvementTypeParams.Add(new SqlParameter("@TimePeriodId", model.Id));

            return new CreateProjectViewModel()
            {
                Survey = model
                ,
                AvailableImprovementTypes = AvailableImprovementTypes(improvementTypeParams)
            };
        }
        public Survey GetCurrentSurvey()
        {
            Survey model = new Survey();

            SqlCommand cmd = new SqlCommand("[Survey].[GetCurrentSurvey]");
            cmd.CommandType = CommandType.StoredProcedure;

            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                if (rdr.Read())
                {

                    model.Id = rdr["TimePeriodId"].ToString().SmartParseDefault<int>(default(int));
                    model.Name = rdr["TimePeriod"].ToString();
                    model.OpeningDate = rdr["OpeningDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
                    model.ClosingDate = rdr["ClosingDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
                    //model.AcceptedDate = rdr["AcceptedDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
                }
                else
                {
                    model = null;
                }
            }
            return model;
        }
        public void SetSurveyDates(Survey model)
        {
            using (SqlCommand command = new SqlCommand("[Survey].[SetSurveyDates]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@TimePeriodId", model.Id);
                if (!model.OpeningDate.Equals(DateTime.MinValue))
                {
                    command.Parameters.AddWithValue("@OpeningDate", model.OpeningDate);
                }
                if (!model.ClosingDate.Equals(DateTime.MinValue))
                {
                    command.Parameters.AddWithValue("@ClosingDate", model.ClosingDate);
                }

                this.ExecuteNonQuery(command);
            }
        }
 public void OpenSurveyNow(Survey model)
 {
     using (SqlCommand command = new SqlCommand("[Survey].[OpenSurveyNow]") { CommandType = CommandType.StoredProcedure })
     {
         command.Parameters.AddWithValue("@TimePeriodId", model.Id);
         this.ExecuteNonQuery(command);
     }
 }
        public Survey GetSurveyDates(Survey model)
        {
            using (SqlCommand command = new SqlCommand("[Survey].[GetSurveyDates]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@TimePeriodId", model.Id);

                using (IDataReader rdr = this.ExecuteReader(command))
                {
                    while (rdr.Read())
                    {
                        model.OpeningDate = rdr["OpeningDate"].ToString().SmartParseDefault<DateTime>(default(DateTime));
                        model.ClosingDate = rdr["ClosingDate"].ToString().SmartParseDefault<DateTime>(default(DateTime));
                    }
                }
            }
            return model;
        }
 public Survey GetSurvey(string year)
 {
     SqlCommand cmd = new SqlCommand("[Survey].[GetSummary]");
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@Year", year);
     Survey model = new Survey();
     using (IDataReader rdr = this.ExecuteReader(cmd))
     {
         if (rdr.Read())
         {
             model.Id = rdr["Id"].ToString().SmartParseDefault<int>(default(int));
             model.Name = rdr["Name"].ToString();
             model.OpeningDate = rdr["OpeningDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
             model.ClosingDate = rdr["ClosingDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
             model.AcceptedDate = rdr["AcceptedDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
         }
         else
         {
             model = null;
         }
     }
     return model;
 }
        /// <summary>
        /// Populate view model for Plan List
        /// </summary>
        /// <returns></returns>
        public ListViewModel GetListViewModel()
        {
            ListViewModel model = new ListViewModel();

            SqlCommand cmd = new SqlCommand("[Survey].[GetList]");
            cmd.CommandType = CommandType.StoredProcedure;

            IList<Survey> surveyList = new List<Survey>();
            Survey sm = null;
            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                //be sure we got a reader
                while (rdr.Read())
                {
                    sm = new Survey();

                    sm.Id = rdr["TimePeriodId"].ToString().SmartParseDefault<int>(default(int));
                    sm.Name = rdr["TimePeriod"].ToString();
                    sm.OpeningDate = rdr["OpeningDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
                    sm.ClosingDate = rdr["ClosingDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);
                    sm.AcceptedDate = rdr["AcceptedDate"].ToString().SmartParseDefault<DateTime>(DateTime.MinValue);

                    surveyList.Add(sm);
                }
            }
            model.SurveyList = surveyList;
            return model;
        }