public async Task SetIdentityCardFace(int Cid, byte[] data) { _logger.Information($"trying to set caregiver with id ({Cid}) Identity Card Face Photo"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var caregiver = await _orphanageDBC.Caregivers.FirstOrDefaultAsync(m => m.Id == Cid); if (caregiver == null) { _logger.Error($"caregiver with id ({Cid}) has not been found, ObjectNotFoundException will be thrown"); throw new ObjectNotFoundException(); } caregiver.IdentityCardPhotoFaceData = data; var ret = await _orphanageDBC.SaveChangesAsync(); if (ret > 0) { _logger.Information($"new Identity Card Face Photo has been set successfully to the caregiver with id ({Cid}), true will be returned"); } else { _logger.Warning($"something went wrong , cannot set new Identity Card Face Photo to the caregiver with id ({Cid}), false will be returned"); } } }
public async Task SetFamilyExclude(int FamId, bool value) { _logger.Information($"trying to set the isExcluded value ({value.ToString()}) to the family with Id({FamId})"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var family = await _orphanageDBC.Families.Where(f => f.Id == FamId).FirstOrDefaultAsync(); if (family == null) { _logger.Error($"family with id ({FamId}) has not been found, ObjectNotFoundException will be thrown"); throw new ObjectNotFoundException(); } family.IsExcluded = value; if (await _orphanageDBC.SaveChangesAsync() > 0) { _logger.Information($"isExcluded value ({value}) has been set successfully to the family with id({FamId})"); } else { _logger.Warning($"isExcluded value ({value}) has not been set to the family with id({FamId}), nothing has changed"); } } }
public async Task SetCaregiverColor(int Fid, int?value) { _logger.Information($"trying to set the color value ({value ?? -1}) to the caregiver with Id({Fid})"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var caregiver = await _orphanageDBC.Caregivers.FirstOrDefaultAsync(m => m.Id == Fid); if (caregiver == null) { _logger.Error($"caregiver with id ({Fid}) has not been found, ObjectNotFoundException will be thrown"); throw new ObjectNotFoundException(); } caregiver.ColorMark = value; if (await _orphanageDBC.SaveChangesAsync() > 0) { _logger.Information($"color value ({value ?? -1}) has been set successfully to the caregiver with id({Fid})"); } else { _logger.Warning($"color value ({value ?? -1}) has not been set to the caregiver with id({Fid}), nothing has changed"); } } }
public async Task <bool> SetFamilyCardPage2(int FamId, byte[] data) { _logger.Information($"trying to set family with id ({FamId}) FamilyCard Page2 Photo"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var family = await _orphanageDBC.Families.Where(f => f.Id == FamId).FirstOrDefaultAsync(); if (family == null) { _logger.Error($"family with id ({FamId}) has not been found, ObjectNotFoundException will be thrown"); throw new ObjectNotFoundException(); } family.FamilyCardImagePage2Data = data; var ret = await _orphanageDBC.SaveChangesAsync(); if (ret > 0) { _logger.Information($"new FamilyCard Page2 Photo has been set successfully to the family with id ({FamId}), true will be returned"); return(true); } else { _logger.Warning($"something went wrong , cannot set new FamilyCard Page2 Photo to the family with id ({FamId}), false will be returned"); return(false); } } }
public async Task <byte[]> GetMotherIdPhotoFace(int Mid) { using (var _orphanageDBC = new OrphanageDBC()) { var img = await _orphanageDBC.Mothers.AsNoTracking().Where(m => m.Id == Mid).Select(m => new { m.IdentityCardPhotoFaceData }).FirstOrDefaultAsync(); return(img?.IdentityCardPhotoFaceData); } }
public async Task <byte[]> GetIdentityCardFace(int Cid) { _logger.Information($"trying to get caregiver with id ({Cid}) Identity Card face photo"); using (var _orphanageDBC = new OrphanageDBC()) { var img = await _orphanageDBC.Caregivers.AsNoTracking().Where(c => c.Id == Cid).Select(c => new { c.IdentityCardPhotoFaceData }).FirstOrDefaultAsync(); if (img?.IdentityCardPhotoFaceData == null) { _logger.Information($"caregiver({Cid}) Identity Card face photo is null"); return(null); } else { _logger.Information($"return caregiver({Cid}) Identity Card face photo, count of bytes are {img?.IdentityCardPhotoFaceData.Length}"); return(img?.IdentityCardPhotoFaceData); } } }
public async Task <byte[]> GetFatherDeathCertificate(int Fid) { _logger.Information($"Trying to get Death Certificate, for the father with id {Fid}"); using (var _orphanageDBC = new OrphanageDBC()) { var img = await _orphanageDBC.Fathers.AsNoTracking().Where(f => f.Id == Fid).Select(f => new { f.DeathCertificatePhotoData }).FirstOrDefaultAsync(); if (img?.DeathCertificatePhotoData != null) { _logger.Information($"the Death Certificate of the father with id {Fid} has {img.DeathCertificatePhotoData.Length} bytes"); return(img?.DeathCertificatePhotoData); } else { _logger.Information($"the Death Certificate of the father with id {Fid} has 0 bytes, null will be returned"); return(null); } } }
public async Task <byte[]> GetFamilyCardPage2(int FamId) { _logger.Information($"trying to get family with id ({FamId}) family card photo page2"); using (var _orphanageDBC = new OrphanageDBC()) { var img = await _orphanageDBC.Families.AsNoTracking().Where(f => f.Id == FamId) .Select(f => new { f.FamilyCardImagePage2Data }).FirstOrDefaultAsync(); if (img?.FamilyCardImagePage2Data == null) { _logger.Information($"family with id({FamId}) family card photo page2"); return(null); } else { _logger.Information($"return family with id({FamId}) family card photo page2, count of bytes are {img?.FamilyCardImagePage2Data.Length}"); return(img?.FamilyCardImagePage2Data); } } }
public async Task SetMotherIdPhotoFace(int Mid, byte[] data) { using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var mother = await _orphanageDBC.Mothers.Where(m => m.Id == Mid).FirstOrDefaultAsync(); if (mother == null) { return; } mother.IdentityCardPhotoFaceData = data; await _orphanageDBC.SaveChangesAsync(); } }
public async Task SetMotherColor(int Mid, int?value) { using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var mother = await _orphanageDBC.Mothers.Where(m => m.Id == Mid).FirstOrDefaultAsync(); if (mother == null) { return; } mother.ColorMark = value; await _orphanageDBC.SaveChangesAsync(); } }
public async Task SetFamilyColor(int FamId, int?colorValue) { try { _logger.Information($"trying to set the color value ({colorValue ?? -1}) to the family with Id({FamId})"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var family = await _orphanageDBC.Families.Where(f => f.Id == FamId).FirstOrDefaultAsync(); if (family == null) { _logger.Error($"family with id ({FamId}) has not been found, ObjectNotFoundException will be thrown"); throw new ObjectNotFoundException(); } family.ColorMark = colorValue; if (await _orphanageDBC.SaveChangesAsync() > 0) { _logger.Information($"color value ({colorValue ?? -1}) has been set successfully to the family with id({FamId})"); } else { _logger.Warning($"color value ({colorValue ?? -1}) has not been set to the family with id({FamId}), nothing has changed"); } } } catch (Exception ex) { throw new ServiceException("Error in SetFamilyCardPage1 method.", ex); } }
public async Task SetFatherPhoto(int Fid, byte[] data) { _logger.Information($"Trying to set Photo, for the father with id {Fid}"); using (var _orphanageDBC = new OrphanageDBC()) { _orphanageDBC.Configuration.AutoDetectChangesEnabled = true; _orphanageDBC.Configuration.LazyLoadingEnabled = true; _orphanageDBC.Configuration.ProxyCreationEnabled = true; var father = await _orphanageDBC.Fathers.Where(f => f.Id == Fid).FirstOrDefaultAsync(); if (father == null) { _logger.Error($"the original father object with id {Fid} object is not founded, ObjectNotFoundException will be thrown"); throw new Exceptions.ObjectNotFoundException(); } father.PhotoData = data; await _orphanageDBC.SaveChangesAsync(); _logger.Information($"new value to Photo has been successfully changed"); } }