Ejemplo n.º 1
0
        public async Task <KhoPhieuXuatChiTiet> UpdatePartial(KhoPhieuXuatChiTiet obj, params string[] field)
        {
            var a = await WithConnection(async c =>
            {
                var objCheck = await c.GetAsync(obj);

                if (objCheck == null)
                {
                    throw new Exception(string.Format("Update id {0} not exist", obj.PhieuXuatChiTietId.ToString()));
                }

                var list = field.ToList();
                var partialUpdateMapping = OrmConfiguration
                                           .GetDefaultEntityMapping <KhoPhieuXuatChiTiet>()
                                           .Clone()
                                           .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true,
                                                                      list.ToArray());

                var result = await c.UpdateAsync(obj, statement => statement.WithEntityMappingOverride(partialUpdateMapping));

                if (result != true)
                {
                    throw new Exception("Update Fail");
                }

                return(obj);
            });

            return(a);
        }
Ejemplo n.º 2
0
        public async Task <KhoPhieuXuatChiTiet> Insert(KhoPhieuXuatChiTiet obj)
        {
            obj.XoaYN = "N";
            return(await WithConnection(async c =>
            {
                await c.InsertAsync(obj);

                if (obj.PhieuXuatChiTietId == 0)
                {
                    throw new Exception("Insert Fail");
                }

                return obj;
            }));
        }
Ejemplo n.º 3
0
        public async Task <KhoPhieuXuatChiTiet> Update(KhoPhieuXuatChiTiet obj)
        {
            return(await WithConnection(async c =>
            {
                var objCheck = await c.GetAsync(obj);

                if (objCheck == null)
                {
                    throw new Exception(string.Format("Update id {0} not exist", obj.PhieuXuatChiTietId.ToString()));
                }

                var result = await c.UpdateAsync(obj);

                if (result != true)
                {
                    throw new Exception("Update Fail");
                }

                return obj;
            }));
        }