Ejemplo n.º 1
0
            public override IRecords QueryPage(int pageNo, int numPerPage)
            {
                //FindPage:第一个参数是页号,从1开始计数;第二个参数是每页记录的个数
                var records = T_Holiday.FindPage(pageNo, numPerPage);

                return(new WrappedRecords <T_Holiday>(records));
            }
Ejemplo n.º 2
0
        public IActionResult Delete(string id)
        {
            T_Holiday.DeleteById(id);
            var referer = this.Request.Headers["Referer"].ToString();

            return(Redirect(referer));
        }
Ejemplo n.º 3
0
            //模型级错误的验证方式。
            //只有不存在属性级错误的时候会调用;如果有属性级错误不会调用
            public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
            {
                var holiday = DateAttribute.FromDateString(this.Day).Value;

                if (T_Holiday.Count(Where.Eq(nameof(T_Holiday.Holiday), holiday)) > 0)
                {
                    yield return(new ValidationResult("该日期已存在。不可加入重复的假期。", new string[] { nameof(Day) }));
                }
            }
Ejemplo n.º 4
0
        public IActionResult Edit(string id)
        {
            var record = T_Holiday.Find(id);
            var vo     = new HolidayVo
            {
                Id   = record.Id,
                Day  = record.Holiday.ToJapanDate(),
                Name = record.Holiday_Name
            };

            return(View(vo));
        }
Ejemplo n.º 5
0
            //模型级错误的验证方式。
            public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
            {
                //逻辑与新规时不太相同
                var holiday = DateAttribute.FromDateString(this.Day).Value;
                var count   = T_Holiday.Count(Where.And(
                                                  Where.Eq(nameof(T_Holiday.Holiday), holiday),
                                                  Where.NotEq(nameof(T_Holiday.Id), this.Id)
                                                  ));

                if (count > 0)
                {
                    yield return(new ValidationResult("该日期已存在。不可加入重复的假期。", new string[] { nameof(Day) }));
                }
            }
Ejemplo n.º 6
0
        public IActionResult Create(HolidayVo vo)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", vo));
            }
            var record = new T_Holiday
            {
                Holiday      = DateAttribute.FromDateString(vo.Day).Value,
                Holiday_Name = vo.Name
            };

            record.Insert();
            return(View(record));
        }
Ejemplo n.º 7
0
        public IActionResult Update(HolidayVo vo)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", vo));
            }
            var record = new T_Holiday
            {
                Id           = vo.Id,
                Holiday      = DateAttribute.FromDateString(vo.Day).Value,
                Holiday_Name = vo.Name
            };

            record.Update();
            return(View(vo));
        }
Ejemplo n.º 8
0
 protected override int QueryRecordsCount()
 {
     return(T_Holiday.Count());
 }
Ejemplo n.º 9
0
        public IActionResult Index()
        {
            var model = T_Holiday.FindAll().ToArray();

            return(View(model));
        }
Ejemplo n.º 10
0
            //QueryAll做全表查询,常用于csv下载
            public override IRecords QueryAll()
            {
                var records = T_Holiday.FindAll();

                return(new HolidayCsvList(records));
            }