Exemple #1
0
        public async Task <KhoPhieuNhapChiTiet> UpdatePartial(KhoPhieuNhapChiTiet 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.PhieuNhapChiTietId.ToString()));
                }

                var list = field.ToList();
                var partialUpdateMapping = OrmConfiguration
                                           .GetDefaultEntityMapping <KhoPhieuNhapChiTiet>()
                                           .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);
        }
Exemple #2
0
        public async Task <KhoPhieuNhapChiTiet> Insert(KhoPhieuNhapChiTiet obj)
        {
            obj.XoaYN = "N";
            return(await WithConnection(async c =>
            {
                await c.InsertAsync(obj);

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

                return obj;
            }));
        }
Exemple #3
0
        public async Task <KhoPhieuNhapChiTiet> Update(KhoPhieuNhapChiTiet 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.PhieuNhapChiTietId.ToString()));
                }

                var result = await c.UpdateAsync(obj);

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

                return obj;
            }));
        }