private void CreateListenersIfNoneExists() { if (0 == _serviceRepository.GetAll().Count) { _serviceRepository.Add(new UdpListener(5757)); _serviceRepository.Add(new TCPListener(5858)); } }
private void AddServiceToDataBase() { Service.serviceType = _ServiceTypeRepo.FirstOrDefault(s => s.Id == Service.serviceType.Id); _ServiceRepository.Add(Service); _ServiceRepository.Save(); StatusMessage = "El servicio fue creado correctamente"; }
public ActionResult Create([Bind(Include = "Name, Description, ImageMimeType, ImageData, UrlString")] Service service, HttpPostedFileBase image = null) { if (!ModelState.IsValid) { return(RedirectToAction("Index", "SiteAdmin")); } if (image != null) { service.ImageMimeType = image.ContentType; service.ImageData = new byte[image.ContentLength]; image.InputStream.Read(service.ImageData, 0, image.ContentLength); } try { _repository.Add(service); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index", "SiteAdmin")); }
public static void Run() { try { log.Debug("--Run HealthCheck--"); if (GetFakeTenant() == 0) { log.ErrorFormat("Error! Could not create tenant alias = {0}", FakeTenantAlias); return; } GetFakeUserId(); var mainLoopPeriod = HealthCheckCfgSectionHandler.Instance.MainLoopPeriod; foreach (var service in HealthCheckCfgSectionHandler.Instance.ServiceNames) { log.DebugFormat("Add service {0} for checking.", service); serviceRepository.Add(service); TimerDictionary.TryAdd(service.ToString(), new Timer(IdleTimeout, service, TimeSpan.Zero, mainLoopPeriod)); } IDriveSpaceChecker spaceChecker = new DriveSpaceChecker(); TimerDictionary.TryAdd(spaceChecker.DriveName, new Timer(IdleTimeoutDriveSpace, spaceChecker.DriveName, TimeSpan.Zero, mainLoopPeriod)); } catch (Exception ex) { log.ErrorFormat("Error on HealthCheckRunner.Run. {0} {1}", ex, ex.InnerException != null ? ex.InnerException.Message : string.Empty); } }
public async Task <IActionResult> AddService(Service service) { await _service1.Add(service); return(RedirectToAction("Index")); }
public async Task <bool> AddAsync(ServiceDTO serviceDTO) { var service = _mapper.Map <ServiceDTO, Service>(serviceDTO); var result = await _serviceRepository.Add(service); return(result); }
public IActionResult Create(Employee employee) { if (ModelState.IsValid) { EmployeeRepository.Add(employee); return(RedirectToAction("Index")); } return(View()); }
public ServiceEntity CreateService(ServiceEntity entity) { entity.IdService = Guid.NewGuid(); entity.CreatedDate = DateTime.Now; entity.UpdatedDate = DateTime.Now; _serviceRepository.Add(entity); return(entity); }
public async Task Handle(AddServiceCommand message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } ServiceAggregateOccurrence occurrence = null; if (message.Occurrence != null) { occurrence = new ServiceAggregateOccurrence { Id = Guid.NewGuid().ToString(), Days = message.Occurrence.Days, StartDate = message.Occurrence.StartDate, EndDate = message.Occurrence.EndDate, StartTime = message.Occurrence.StartTime, EndTime = message.Occurrence.EndTime }; } var service = new ServiceAggregate { Id = message.Id, Name = message.Name, Description = message.Description, PartialImagesUrl = message.Images, Price = message.Price, Tags = message.Tags, ShopId = message.ShopId, CreateDateTime = message.CreateDateTime, UpdateDateTime = message.UpdateDateTime, TotalScore = 0, AverageScore = 0, Occurrence = occurrence }; if (!await _serviceRepository.Add(service)) { return; } _eventPublisher.Publish(new ServiceAddedEvent { Id = message.Id, Name = message.Name, Description = message.Description, Price = message.Price, ShopId = message.ShopId, CreateDateTime = message.CreateDateTime, UpdateDateTime = message.UpdateDateTime, CommonId = message.CommonId }); }
public async Task <ActionResult <Service> > Create(Service value) { //Service obj = new Service(value); _service.Add(value); // it will be null //var testService = await _service.GetById(value.); // If everything is ok then: await _uow.Commit(); // The product will be added only after commit // testProduct = await _productRepository.GetById(product.Id); return(RedirectToAction("Index")); }
public void Register(ServiceCollection services) { var list = services.Services .Select(s => new DkmsServiceEntity { Host = services.Host, Service = s }).ToList(); var currents = _serviceQueryRepository.QueryByHost(services.Host); var news = list.Where(s => !currents.Any(x => s.Service == s.Service)); _serviceRepository.Add(news); var removes = currents.Where(s => !news.Any(x => s.Service == s.Service)); _serviceRepository.Delete(removes); }
public async Task <ActionResult> Add(ServiceAddDto addServiceDto) { if (await _serviceRepository.GetByNameAsync(addServiceDto.Name) != null) { return(BadRequest("Servicio ya existente!")); } var service = _mapper.Map <Service>(addServiceDto); _serviceRepository.Add(service); if (await _serviceRepository.SaveAllAsync()) { return(Ok()); } return(BadRequest("Error al agregar el servicio")); }
public async Task <IActionResult> Post([FromBody] Service service) { try { _logger.LogInformation("Adding new service."); await _serviceRepository.Add(service); var url = Url.Link("ServiceGet", new { id = service.Id }); return(Created(url, service)); } catch (Exception e) { _logger.LogError("Error during adding new service", e); } return(BadRequest()); }
public async Task <IActionResult> CreateService([FromBody] SaveServicesResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } resource.ServiceProviderId = await GetServiceProviderId(); var service = _mapper.Map <SaveServicesResource, Service>(resource); _repository.Add(service); await _unitOfWork.CompleteAsync(); var result = _mapper.Map(service, resource); return(Ok(result)); }
public IActionResult Create(ServiceCreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadedFile(model); Services newService = new Services { ServiceGroup = model.ServiceGroup, Name = model.Name, ServiceStatus = model.ServiceStatus, PhotoPath = uniqueFileName }; _serviceRepository.Add(newService); return(RedirectToAction("index", "service")); } return(View()); }
public async Task AddService(ServiceDTO service, string operatorId) { if (!string.IsNullOrEmpty(service?.Station?.StreetAddress)) { var lonLat = await _amapProxy.Geo(service.Station.StreetAddress); service.Station.Longitude = lonLat?.Longitude ?? 0; service.Station.Latitude = lonLat?.Latitude ?? 0; } var obj = ServiceFactory.CreateInstance( service.Title, service.Introduction, service.SincerityGold, service.ServeScope, service.Category, service.SubCategory, service.Station, service.OrganizationId, operatorId, service.ApplicationId); _serviceRepository.Add(obj); if (service.Images != null && service.Images.Count() > 0) { foreach (var img in service.Images) { _serviceImageRepository.Add(new ServiceImage { CreatedOn = DateTime.Now, ImageId = img.ImageId, ServiceId = obj.Id }); } } _dbUnitOfWork.Commit(); }
public IHttpActionResult AddService([FromBody] ServiceModel service) { serviceRepository.Add(service); return(Ok()); }
public void CreateService(Services Service) { _repository.Add(Service); }
public bool createService(Service serv) => service.Add(serv);
public void InitDataBase() { if (_webConfigRepository.GetFilter(it => it.IsInitialed == true).FirstOrDefault() != null) { return; } _webConfigRepository.Add(new WebConfig() { IsInitialed = true }); #region 领域服务 Type[] types = Assembly.GetExecutingAssembly().GetTypes(); if (types != null && types.Count() > 0) { foreach (var service in types) { if (service.GetInterfaces().Contains(typeof(IDomainService))) { //TODO Service s = new Service() { Assembly = Assembly.GetExecutingAssembly().FullName, FullName = service.FullName }; MethodInfo[] methodInfos = service.GetMethods(); if (methodInfos != null && methodInfos.Count() > 0) { foreach (var type in methodInfos) { ServiceMethod sm = new ServiceMethod() { Name = type.Name }; if (s.Methods == null) { s.Methods = new List <ServiceMethod>(); } s.Methods.Add(sm); } } _serviceRepository.Add(s); } } } #endregion #region 用户、角色 UserGroup ug1 = new UserGroup() { Name = Constant.DEFAULT_USERGROUP }; Role r1 = new Role() { Name = Constant.ANONYMOUS_ROLE, RoleType = RoleType.UnKnown }; Role r2 = new Role() { Name = Constant.MANAGER_ROLE, RoleType = RoleType.SysBuiltIn }; User u1 = new User() { AccountName = Constant.SUPERMANAGER_USER, AccountPassword = Constant.SUPERMANAGER_USER, Role = r2, AccountInfo = new AccountInfo() { LoginCount = 0, LoginDate = DateTime.Today, LoginIP = "192.168.5.108", RegisterDate = DateTime.Today, RegisterIp = "192.168.5.108" }, UserGroup = ug1, PersonalInfo = new PersonalInfo() { Age = 28, Email = "*****@*****.**", Fax = "34510996", Name = "HY", Phone = "15975455335", Sex = Sex.Male, Tel = "87072280" } }; User u2 = new User() { AccountName = Constant.SUPERMANAGER_USER, AccountPassword = Constant.SUPERMANAGER_USER, Role = r1, AccountInfo = new AccountInfo() { LoginCount = 0, LoginDate = DateTime.Today, LoginIP = "192.168.5.108", RegisterDate = DateTime.Today, RegisterIp = "192.168.5.108" }, UserGroup = ug1, PersonalInfo = new PersonalInfo() { Age = 28, Email = "*****@*****.**", Fax = "34510996", Name = "POLAN", Phone = "15975455335", Sex = Sex.Male, Tel = "87072280" } }; _userRepository.Add(u1); _userRepository.Add(u2); #endregion #region 预置目录 ModuleMenu mm1 = new ModuleMenu() { IsEnable = true, CreateDateTime = DateTime.Now, IsDeleted = false, IsPage = false, IsVisible = true, MenuCode = "ModuleMenu", MenuName = "系统设置", URL = "/Home/GetBackStageSecondaryMenu", MenuType = MenuType.BackStage, Children = new List <ModuleMenu>() { new ModuleMenu() { IsEnable = true, CreateDateTime = DateTime.Now, IsDeleted = false, IsPage = false, IsVisible = true, MenuCode = "MenuSetting", MenuName = "目录设置", MenuType = MenuType.BackStage, URL = "/Menu/EditMenu" } } }; //ModuleMenu mm1 = new ModuleMenu() //{ // IsEnable = true, // Children = new List<ModuleMenu>() { // new ModuleMenu() // { // IsEnable=true // } // } //}; this._moduleMenuRepository.Add(mm1); #endregion _unitOfWork.Commit(); }
public ResponseModel CreateServiceForCompany(AddMultipleServicesModel model) { var resp = new ResponseModel(); try { var company = _companyRepository.GetById(Guid.Parse(model.CompanyId)); if (company == null) { resp.Result = "Não foi possível encontrar a empresa"; return(resp); } if (model.Services != null && model.Services.Count > 0) { if (model.Services.All(x => x.DurationMinutes > 0)) { if (model.Services.All(x => x.Name != null && x.Name != String.Empty)) { var servicesCompany = _serviceRepository.GetServicesByCompanyId(company.CompanyId); model.Services.ForEach(serviceModel => { // não adicionar dois serviços com o mesmo nome na empresa if (servicesCompany.All(x => x.Name.ToLowerInvariant() != serviceModel.Name.ToLowerInvariant())) { MeAgendaAi.Domain.Entities.Services service = new MeAgendaAi.Domain.Entities.Services { ServiceId = Guid.NewGuid(), CompanyId = company.CompanyId, Name = serviceModel.Name, DurationMinutes = serviceModel.DurationMinutes, CreatedAt = DateTimeUtil.UtcToBrasilia(), LastUpdatedAt = DateTimeUtil.UtcToBrasilia() }; _serviceRepository.Add(service); } }); resp.Success = true; resp.Message = "Serviços adicionados à empresa com sucesso"; } else { resp.Message = "Adicione um nome para o serviço"; } } else { resp.Message = "Tempo de duração do serviço deve ser maior do que zero"; } } else { resp.Message = "Lista de serviços vazia, adicione algum serviço"; } } catch (Exception) { resp.Message = "Não foi possível adicionar o serviço"; } return(resp); }
public Model.Models.Service Add(Model.Models.Service service) { return(_serviceRepository.Add(service)); }
public async Task AddService(ServiceDTO service, string operatorId) { if (string.IsNullOrWhiteSpace(service.IOSVideoUrl) && string.IsNullOrWhiteSpace(service.VideoUrl)) { throw new ArgumentInvalidException("IOSVideoUrl和VideoUrl不能都为空!"); } if (!string.IsNullOrEmpty(service?.Station?.StreetAddress)) { var lonLat = await _amapProxy.Geo(service.Station.StreetAddress); service.Station.Longitude = lonLat?.Longitude ?? 0; service.Station.Latitude = lonLat?.Latitude ?? 0; } var user = await _userServiceProxy.GetCookAppUser(operatorId); var orgId = ""; if (user != null) { var servicer = _servicerRepository.GetFiltered(o => o.UserName == user.UserName).FirstOrDefault(); if (servicer != null) { orgId = servicer.OrganizationId; } } if (!string.IsNullOrEmpty(orgId)) { var c = _serviceRepository.GetFiltered(o => o.OrganizationId == orgId && o.Title == service.Title).Count(); if (c > 0) { throw new ArgumentInvalidException("您所在的商户下已经存在您所发布的标题,请更改标题!"); } } var obj = ServiceFactory.CreateInstance( service.Title, service.Introduction, service.SincerityGold, service.ServeScope, service.Category, service.SubCategory, service.Station, string.IsNullOrEmpty(orgId) ? service.OrganizationId : orgId, operatorId, service.VideoUrl, service.IOSVideoUrl, service.GoodsCategoryName, service.ApplicationId); _serviceRepository.Add(obj); if (service.Images != null && service.Images.Count() > 0) { foreach (var img in service.Images) { _serviceImageRepository.Add(new ServiceImage { CreatedOn = DateTime.Now, ImageId = img.ImageId, ServiceId = obj.Id }); } } _dbUnitOfWork.Commit(); }
public async Task <Service> Add(Service service) { var data = await _serviceRepository.Add(ServiceMapper.Map(service)); return(service); }
public void Add(ServiceViewModel service) { _serviceRepository.Add(service); }
public void AddAssetsService(ServiceAttribute item) { _assetsServiceRep.Add(item); }
public void Add(Services entity) { serviceRepository.Add(entity); SaveChanges(); }
public async Task <Service> AddService(Service service) { var addedEntity = await _serviceRepository.Add(ServiceMapper.Map(service)); return(ServiceMapper.Map(addedEntity)); }