public async Task <bool> AddLogoFile(Stream stream, string filename, int serviceId) { if (await _fileRepository.Save(stream, "serviceslogo/" + serviceId + "/" + filename)) { var service = await _serviceInfoRepository.GetById(serviceId); service.Logo = filename; return(await _serviceInfoRepository.Update(service)); } else { return(await Task.FromResult(false)); } }
public void Update(ServiceInfo serviceInfo) { try { if (serviceInfo.Id < 0) { throw new ArgumentException(); } if (String.IsNullOrEmpty(serviceInfo.Name) || String.IsNullOrEmpty(serviceInfo.Description)) { throw new ArgumentException(); } if (serviceInfo.Value < 0) { throw new ArgumentException(); } _serviceInfoRepository.Update(serviceInfo); _logger.CreateLog("Database", "Update", "ServiceInfo", new string[] { serviceInfo.Id.ToString(), serviceInfo.Name, serviceInfo.Description, serviceInfo.Value.ToString() }); } catch (Exception ex) { _logger.CreateLog("Error", ex.ToString()); throw ex; } }
/// <summary> /// Saves the heartBeatEntity. /// </summary> /// <param name="serviceInfoEntity">The service info heartBeatEntity.</param> /// <param name="repository">The repository.</param> /// <param name="updateAction">The update action.</param> private static void Save( ServiceInfoEntity serviceInfoEntity, IServiceInfoRepository repository, Action <IModifierExpression <ServiceInfoEntity, ObjectId> > updateAction) { if (serviceInfoEntity == null) { return; } if (serviceInfoEntity.Id == ObjectId.Empty) { repository.Save(serviceInfoEntity); } else { repository.Update(serviceInfoEntity.Id, bd => { updateAction(bd); SetValueMonitoring(bd, serviceInfoEntity); }); } }
/// <summary> /// Saves the heartBeatEntity. /// </summary> /// <param name="serviceInfoEntity">The service info heartBeatEntity.</param> /// <param name="repository">The repository.</param> /// <param name="updateAction">The update action.</param> private static void Save( ServiceInfoEntity serviceInfoEntity, IServiceInfoRepository repository, Action<IModifierExpression<ServiceInfoEntity, ObjectId>> updateAction) { if (serviceInfoEntity == null) return; if (serviceInfoEntity.Id == ObjectId.Empty) repository.Save(serviceInfoEntity); else { repository.Update(serviceInfoEntity.Id, bd => { updateAction(bd); SetValueMonitoring(bd, serviceInfoEntity); }); } }