コード例 #1
0
        /*public string MaKhoTaiKhoan { get; set; }
         * public string TenKhoTaiKhoan { get; set; }
         * public string GhiChu { get; set; } */
        #endregion

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

                var taikhoan = new Entity.MSSQL_QLDN_QLNS.Entity.KhoTaiKhoan();
                taikhoan.TenTaiKhoan = TenTaiKhoan;
                taikhoan.MaTaiKhoan  = MaTaiKhoan;
                taikhoan.GhiChu      = GhiChu;
                taikhoan.NguoiTao    = NguoiTao;
                taikhoan.NgayTao     = DateTime.Now;
                taikhoan.XoaYN       = "N";
                taikhoan.CtrVersion  = 1;
                KhoTaiKhoanRepository repo = new KhoTaiKhoanRepository(context);
                await repo.Insert(taikhoan);

                return(returnActionResult(HttpStatusCode.OK, taikhoan, 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 <ActionResultDto> Execute(ContextDto context)
        {
            GetListKhoTaiKhoanByCriteriaBiz biz = new GetListKhoTaiKhoanByCriteriaBiz(context);
            var result = new ActionResultDto();

            try
            {
                var _draw   = Protector.Int(draw);
                var _start  = Protector.Int(start);
                var _length = Protector.Int(length);

                /* =========================
                 * fixed input
                 * ========================= */
                sortName = string.IsNullOrEmpty(sortName) ? "TaiKhoanId" : sortName;
                sortDir  = string.IsNullOrEmpty(sortDir) ? "asc" : sortDir;
                _length  = _length < 1 ? 10 : _length;
                fields   = string.IsNullOrEmpty(fields) ? "a.TaiKhoanId,a.MaNhom,a.TenNhom,a.MoTa,b.HoTen as NguoiTao,a.NgayTao,a.XoaYN" : fields;

                var whereClause = search;
                var orderClause = sortName + " " + sortDir;
                var total       = 0;

                biz.FieldsField = fields;
                biz.WhereClause = whereClause;
                biz.OrderClause = orderClause;
                biz.Skip        = _start;
                biz.Take        = _length;

                KhoTaiKhoanRepository repo            = new KhoTaiKhoanRepository(context);
                IEnumerable <dynamic> listKhoTaiKhoan = await biz.Execute();

                if (listKhoTaiKhoan.Count() > 0)
                {
                    var obj = listKhoTaiKhoan.FirstOrDefault();

                    total = Protector.Int(obj.MAXCNT);
                }

                dynamic _metaData = new System.Dynamic.ExpandoObject();
                _metaData.draw  = _draw;
                _metaData.total = total;

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, listKhoTaiKhoan, _metaData));
            }
            catch (Exception ex)
            {
                result.ReturnCode = HttpStatusCode.InternalServerError;
                result.ReturnData = new
                {
                    error = new
                    {
                        code    = HttpStatusCode.InternalServerError,
                        type    = HttpStatusCode.InternalServerError.ToString(),
                        message = ex.InnerException != null ? ex.InnerException.Message : ex.Message
                    }
                };
                return(result);
            }
        }
コード例 #3
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var count = 0;

                var repo = new KhoTaiKhoanRepository(context);

                for (int i = 0; i < _listId.Count; i++)
                {
                    if (_listId[i] > 0 && await repo.Delete(_listId[i]))
                    {
                        count++;
                    }
                }

                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));
            }
        }
コード例 #4
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                dynamic result = new System.Dynamic.ExpandoObject();

                var repo = new KhoTaiKhoanRepository(context);
                await repo.UpdatePartial(this,
                                         nameof(TenTaiKhoan),
                                         nameof(MaTaiKhoan),
                                         nameof(GhiChu)
                                         );

                result.data = this;
                return(result);
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
コード例 #5
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            dynamic result = new System.Dynamic.ExpandoObject();

            var repo = new KhoTaiKhoanRepository(context);
            await repo.Delete(Id);

            result.data = await repo.Delete(Id);

            return(result);
        }
コード例 #6
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 _KhoTaiKhoanId = Protector.Int(KhoTaiKhoanId);

                var repo        = new KhoTaiKhoanRepository(context);
                var KhoTaiKhoan = await repo.GetById(_KhoTaiKhoanId);

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

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

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