Example #1
0
        public async Task <KhoPhieuNhapSeries> UpdatePartial(KhoPhieuNhapSeries sr, params string[] field)
        {
            var a = await WithConnection(async c =>
            {
                KhoPhieuNhapSeries obj = await c.GetAsync(sr);

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

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

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

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

                return(sr);
            });

            return(a);
        }
Example #2
0
        public async Task <KhoPhieuNhapSeries> Insert(KhoPhieuNhapSeries sr)
        {
            return(await WithConnection(async c =>
            {
                await c.InsertAsync(sr);

                if (sr.Id == 0)
                {
                    throw new Exception("Insert Fail");
                }

                return sr;
            }));
        }
Example #3
0
        public async Task <KhoPhieuNhapSeries> Update(KhoPhieuNhapSeries sr)
        {
            return(await WithConnection(async c =>
            {
                KhoPhieuNhapSeries obj = await c.GetAsync(sr);

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

                var result = await c.UpdateAsync(sr);

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

                return sr;
            }));
        }