Exemplo n.º 1
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var count = 0;

                var repo = new KhoHangHoaRepository(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));
            }
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            dynamic result = new System.Dynamic.ExpandoObject();

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

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

            return(result);
        }
Exemplo n.º 4
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));
            }
        }
Exemplo n.º 5
0
        /*public string MaKhoHangHoa { get; set; }
         * public string TenKhoHangHoa { get; set; }
         * public string GhiChu { get; set; } */
        #endregion

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

                var hanghoa = new Entity.MSSQL_QLDN_QLNS.Entity.KhoHangHoa();
                hanghoa.MaHangHoa       = MaHangHoa;
                hanghoa.TenHangHoa      = TenHangHoa;
                hanghoa.TuKhoa          = TuKhoa;
                hanghoa.DonViTinh       = DonViTinh;
                hanghoa.GiaMua          = GiaMua;
                hanghoa.GiaBan          = GiaBan;
                hanghoa.ThueMua         = ThueMua;
                hanghoa.ThueBan         = ThueBan;
                hanghoa.CauHinh         = CauHinh;
                hanghoa.Hinh            = Hinh;
                hanghoa.ThoiGianBaoHanh = ThoiGianBaoHanh;
                hanghoa.NhomHangHoaId   = NhomHangHoaId;
                hanghoa.LoaiHangHoaId   = LoaiHangHoaId;
                hanghoa.NhaCungCapId    = NhaCungCapId;
                hanghoa.HangSanXuatId   = HangSanXuatId;
                hanghoa.NuocSanXuatId   = NuocSanXuatId;
                hanghoa.MoTa            = MoTa;
                hanghoa.GhiChu          = GhiChu;
                hanghoa.NguoiTao        = NguoiTao;
                hanghoa.NgayTao         = DateTime.Now;
                hanghoa.XoaYN           = "N";
                KhoHangHoaRepository repo = new KhoHangHoaRepository(context);
                await repo.Insert(hanghoa);

                InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction();
                ls.InsertKhoLuocSu(context, "KhoHangHoa", hanghoa.HangHoaId, "Insert", hanghoa.NguoiTao);
                return(returnActionResult(HttpStatusCode.OK, hanghoa, 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));
            }
        }