Exemplo n.º 1
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 _PhongBanId = Protector.Int(PhongBanId);

                var repo = new PhongBanRepository(context);
                var PhongBan = await repo.GetById(_PhongBanId);

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

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

                return _result;
            }
            catch (Exception ex)
            {
                return returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }
        }
        public ActionResult Edit(int id)
        {
            var phongban = phongbanRepo.GetById(id);

            return(Json(phongban));
        }