Ejemplo n.º 1
0
        public ActionResult SearchAction(StatByRegionViewModel model)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(model.SearchConditions["StartDate"]))
                {
                    model.Start = Constants.MinDate;
                }
                else
                {
                    DateTime result = Constants.MinDate;
                    bool isSuccess = DateTime.TryParse(model.SearchConditions["StartDate"], out result);
                    model.Start = isSuccess ? result : Constants.MinDate;
                }

                if (String.IsNullOrWhiteSpace(model.SearchConditions["EndDate"]))
                {
                    model.End = DateTime.MaxValue;
                }
                else
                {
                    DateTime result = DateTime.MaxValue;
                    bool isSuccess = DateTime.TryParse(model.SearchConditions["EndDate"], out result);
                    model.End = isSuccess ? result : DateTime.MaxValue;
                }

                model.QueryData();
                model.CountTotalRows();

                return View(model);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return View(model);
            }
        }