コード例 #1
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();
                var repo = new KhoHangHoaRepository(context);
                if (_KhoHangHoa != null)
                {
                    var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoHangHoa();
                    congviecEntity.HangHoaId = _KhoHangHoa.HangHoaId;

                    congviecEntity.XoaYN = "Y";

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

                    _KhoHangHoa.XoaYN = congviecEntity.XoaYN;
                    InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction();
                    ls.InsertKhoLuocSu(context, "KhoHangHoa", _KhoHangHoa.HangHoaId, "Delete", 0);
                }
                else
                {
                    if (_listKhoHangHoa != null && _listKhoHangHoa.Count > 0)
                    {
                        foreach (var congviecModel in _listKhoHangHoa)
                        {
                            if (congviecModel.HangHoaId > 0)
                            {
                                var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoHangHoa();
                                congviecEntity.HangHoaId = congviecModel.HangHoaId;

                                congviecEntity.XoaYN = "Y";

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

                                congviecModel.XoaYN = congviecEntity.XoaYN;
                                InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction();
                                ls.InsertKhoLuocSu(context, "KhoHangHoa", congviecEntity.HangHoaId, "Delete", congviecEntity.NguoiTao);
                            }
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listKhoHangHoa, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
コード例 #2
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                dynamic result = new ActionResultDto();

                var repo = new KhoHangHoaRepository(context);
                await repo.UpdatePartial(this,
                                         nameof(MaHangHoa),
                                         nameof(TenHangHoa),
                                         nameof(TuKhoa),
                                         nameof(DonViTinh),
                                         nameof(GiaMua),
                                         nameof(GiaBan),
                                         nameof(ThueMua),
                                         nameof(ThueBan),
                                         nameof(CauHinh),
                                         nameof(Hinh),
                                         nameof(ThoiGianBaoHanh),
                                         nameof(NhomHangHoaId),
                                         nameof(LoaiHangHoaId),
                                         nameof(NhaCungCapId),
                                         nameof(HangSanXuatId),
                                         nameof(NuocSanXuatId),
                                         nameof(MoTa),
                                         nameof(GhiChu)
                                         );

                result.ReturnCode = HttpStatusCode.OK;
                result.ReturnData = new
                {
                    data = this
                };
                InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction();
                ls.InsertKhoLuocSu(context, "KhoHangHoa", HangHoaId, "Update", NguoiTao);
                return(result);
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }