Beispiel #1
0
 public static LoaiVanBanInfo ToDataInfo(this LoaiVanBanResult entity)
 {
     return(new LoaiVanBanInfo
     {
         Id = entity.Id,
         Name = entity.Ten
     });
 }
        public SaveResult Delete(LoaiVanBanResult entity)
        {
            return(ExecuteDbWithHandle(_logService, () =>
            {
                using (var context = new TechOfficeEntities())
                {
                    var vb = context.LoaiVanBans.Single(x => x.Id == entity.Id && x.IsDeleted == false);

                    vb.IsDeleted = true;
                    vb.LastUpdatedBy = entity.LastUpdatedBy;
                    vb.LastUpdated = DateTime.Now;

                    context.Entry(vb).State = EntityState.Modified;
                    return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }));
        }
        public async Task <SaveResult> AddAsync(LoaiVanBanResult entity)
        {
            return(await ExecuteDbWithHandleAsync(_logService, async() =>
            {
                using (var context = new TechOfficeEntities())
                {
                    var add = context.LoaiVanBans.Create();

                    add.Ten = entity.Ten;
                    add.MoTa = entity.MoTa;

                    add.IsDeleted = entity.IsDeleted;
                    add.CreatedBy = entity.CreatedBy;
                    add.CreateDate = DateTime.Now;

                    context.Entry(add).State = EntityState.Added;
                    return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }));
        }
        public async Task <SaveResult> UpdateAsync(LoaiVanBanResult entity)
        {
            return(await ExecuteDbWithHandleAsync(_logService, async() =>
            {
                using (var context = new TechOfficeEntities())
                {
                    var update = context.LoaiVanBans.Single(x => x.Id == entity.Id && x.IsDeleted == false);

                    update.Ten = entity.Ten;
                    update.MoTa = entity.MoTa;
                    update.IsDeleted = entity.IsDeleted;
                    update.LastUpdatedBy = entity.LastUpdatedBy;
                    update.LastUpdated = DateTime.Now;

                    context.Entry(update).State = EntityState.Modified;

                    return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE;
                }
            }));
        }
Beispiel #5
0
 public static LoaiVanBanInfo ToIfNotNullDataInfo(this LoaiVanBanResult entity)
 {
     return(entity?.ToDataInfo());
 }