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 <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 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 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 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"); } }