Пример #1
0
        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));
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        /// <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);
                });
            }
        }
Пример #4
0
        /// <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);
                                                            });
            }
        }