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

                var count = 0;

                var repo = new CongViecRepository(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, "ListCongViec", _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));
            }
        }
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();
                var repo = new CongViecRepository(context);
                if (_CongViec != null)
                {
                    var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.CongViec();
                    congviecEntity.CongViecId = _CongViec.CongViecId;
                    congviecEntity.CtrVersion = _CongViec.CtrVersion;

                    congviecEntity.XoaYN = "Y";

                    congviecEntity = await repo.UpdatePartial(congviecEntity,
                                                              nameof(Entity.MSSQL_QLDN_QLNS.Entity.CongViec.XoaYN)
                                                              );

                    _CongViec.XoaYN = congviecEntity.XoaYN;
                }
                else
                {
                    if (_listCongViec != null && _listCongViec.Count > 0)
                    {
                        foreach (var congviecModel in _listCongViec)
                        {
                            if (congviecModel.CongViecId > 0)
                            {
                                var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.CongViec();
                                congviecEntity.CongViecId = congviecModel.CongViecId;
                                congviecEntity.CtrVersion = congviecModel.CtrVersion;

                                congviecEntity.XoaYN = "Y";

                                congviecEntity = await repo.UpdatePartial(congviecEntity,
                                                                          nameof(Entity.MSSQL_QLDN_QLNS.Entity.CongViec.XoaYN)
                                                                          );

                                congviecModel.XoaYN = congviecEntity.XoaYN;
                            }
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listCongViec, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #3
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                var congviec = new Entity.MSSQL_QLDN_QLNS.Entity.CongViec();
                congviec.DuAnId = Protector.Int(DuAnId);
                congviec.TieuDe = TieuDe;
                congviec.MoTa   = MoTa;
                if (NgayBatDau != "" && NgayBatDau != null)
                {
                    congviec.NgayBatDau = DateTime.ParseExact(NgayBatDau, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR"));
                }
                if (NgayThatSuBatDau != null && NgayThatSuBatDau != "")
                {
                    congviec.NgayThatSuBatDau = DateTime.ParseExact(NgayThatSuBatDau, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR"));
                }
                if (NgayKetThuc != null && NgayKetThuc != "")
                {
                    congviec.NgayKetThuc = DateTime.ParseExact(NgayKetThuc, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR"));
                }
                if (NgayThatSuKetThuc != null && NgayThatSuKetThuc != "")
                {
                    congviec.NgayThatSuKetThuc = DateTime.ParseExact(NgayThatSuKetThuc, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR"));
                }
                congviec.SoNgay           = Protector.Decimal(SoNgay);
                congviec.TienDo           = Protector.Int(TienDo);
                congviec.NoiDungCongViec  = NoiDungCongViec;
                congviec.ThuanLoiKhoKhan  = ThuanLoiKhoKhan;
                congviec.GiaiPhapKienNghi = GiaiPhapKienNghi;
                congviec.MaTrangThai      = MaTrangThai;
                congviec.NguoiXuLy        = Protector.Int(NguoiXuLy);
                congviec.NguoiTao         = Protector.Int(NguoiTao);
                congviec.GhiChu           = GhiChu;
                congviec.XoaYN            = "N";
                congviec.CtrVersion       = 1;
                CongViecRepository repo = new CongViecRepository(context);
                await repo.Insert(congviec);

                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "CongViec", congviec.CongViecId, "Insert", congviec.NguoiTao);

                return(returnActionResult(HttpStatusCode.OK, congviec, 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));
            }
        }
Exemple #4
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                dynamic result = new System.Dynamic.ExpandoObject();
                var     repo   = new CongViecRepository(context);
                await repo.UpdatePartial(this,
                                         nameof(DuAnId),
                                         nameof(TieuDe),
                                         nameof(MoTa),
                                         nameof(NgayBatDau),
                                         nameof(NgayKetThuc),
                                         nameof(NgayThatSuBatDau),
                                         nameof(NgayThatSuKetThuc),
                                         nameof(SoNgay),
                                         nameof(TienDo),
                                         nameof(NoiDungCongViec),
                                         nameof(ThuanLoiKhoKhan),
                                         nameof(GiaiPhapKienNghi),
                                         nameof(MaTrangThai),
                                         nameof(NguoiXuLy)
                                         );

                result.data = this;
                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "CongViec", CongViecId, "Update", NguoiTao);
                return(returnActionResult(this, null));
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }