Exemplo n.º 1
0
        /// <summary>
        /// Ham xu ly chinh, chi nhan 1 bien moi truong
        /// </summary>
        /// <param name="context">Bien moi truong</param>
        /// <returns></returns>
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                Init();
                Validate();

                var repo = new LoaiNghiPhepRepository(context);

                var loainghiphep = new Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep();
                loainghiphep.LoaiNghiPhepId = _loainghiphepId;

                loainghiphep.MaLoaiNghiPhep = this.MaLoaiNghiPhep;
                loainghiphep.TenLoaiPhep    = this.TenLoaiPhep;
                loainghiphep.SoNgay         = this.SoNgay;
                loainghiphep.GhiChu         = this.GhiChu;
                loainghiphep.CtrVersion     = _CtrVersion;

                loainghiphep = await repo.UpdatePartial(loainghiphep,
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.MaLoaiNghiPhep),
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.TenLoaiPhep),
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.SoNgay),
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.GhiChu),
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.LoaiNghiPhepId),
                                                        nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.CtrVersion)
                                                        );

                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "LoaiNghiPhep", _loainghiphepId, "Update", NguoiTao);

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, loainghiphep, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                if (_listObj != null && _listObj.Count > 0)
                {
                    var repo = new LoaiNghiPhepRepository(context);

                    foreach (var obj in _listObj)
                    {
                        if (obj.LoaiNghiPhepId > 0)
                        {
                            var objEntity = new Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep();
                            objEntity.LoaiNghiPhepId = obj.LoaiNghiPhepId;
                            objEntity.CtrVersion     = obj.CTRVERSION;

                            objEntity.XoaYN = "Y";

                            objEntity = await repo.UpdatePartial(objEntity,
                                                                 nameof(Entity.MSSQL_QLDN_QLNS.Entity.LoaiNghiPhep.XoaYN)
                                                                 );

                            obj.XoaYN = objEntity.XoaYN;
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listObj, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }