public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var count = 0;

                var repo = new KhenThuongRepository(context);

                for (int i = 0; i < _listId.Count; i++)
                {
                    if (_listId[i] > 0 && await repo.Delete(_listId[i]))
                    {
                        count++;
                        InsertLuocSuAction ls = new InsertLuocSuAction();
                        ls.InsertLuocSu(context, "ListKhenThuong", _listId[i], "Delete", 0);
                    }
                }

                return(returnActionResult(HttpStatusCode.OK, count, null));
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
示例#2
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                dynamic result = new System.Dynamic.ExpandoObject();
                var     repo   = new KhenThuongRepository(context);
                await repo.UpdatePartial(this,
                                         nameof(Ngay),
                                         nameof(Tien),
                                         nameof(BangChu),
                                         nameof(LyDo),
                                         nameof(HinhThuc),
                                         nameof(VanBanSo)
                                         );

                result.data = this;
                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "KhenThuong", KhenThuongId, "Update", NguoiTao);
                return(returnActionResult(this, null));
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
示例#3
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                var khenthuong = new Entity.MSSQL_QLDN_QLNS.Entity.KhenThuong();
                khenthuong.Ngay       = DateTime.ParseExact(ngay, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR"));
                khenthuong.Tien       = Protector.Int(Tien);
                khenthuong.BangChu    = BangChu;
                khenthuong.LyDo       = LyDo;
                khenthuong.HinhThuc   = Protector.Short(HinhThuc);
                khenthuong.VanBanSo   = Protector.Int(VanBanSo);
                khenthuong.NgayTao    = DateTime.Now;
                khenthuong.NguoiTao   = Protector.Int(NguoiTao);
                khenthuong.XoaYN      = "N";
                khenthuong.CtrVersion = 1;

                KhenThuongRepository repo = new KhenThuongRepository(context);
                await repo.Insert(khenthuong);

                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "KhenThuong", khenthuong.KhenThuongId, "Insert", 0);
                return(returnActionResult(HttpStatusCode.OK, khenthuong, null));
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
示例#4
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            var _result = new ActionResultDto();

            try
            {
                /* kiểm tra input */
                var _error = validate();

                if (_error.code > 0)
                {
                    return(returnActionError(HttpStatusCode.BadRequest, _error.message));
                }

                /* convert input */
                var _KhenThuongId = Protector.Int(KhenThuongId);

                var repo       = new KhenThuongRepository(context);
                var KhenThuong = await repo.GetById(_KhenThuongId);

                if (KhenThuong == null)
                {
                    return(returnActionError(HttpStatusCode.BadRequest, string.Format("Không tìm thấy KhenThuongId '{0}'", _KhenThuongId)));
                }

                _result.ReturnCode = HttpStatusCode.OK;
                _result.ReturnData = new
                {
                    data = KhenThuong
                };

                return(_result);
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }