public ZoneDto AddZone(AddZoneCommand cmd) { var zone = new Zone(cmd.Name, cmd.Description, cmd.Channel, cmd.IsEnabled); zoneRepository.Add(zone); controlService.Register(zone.Channel); return(new ZoneDto(zone.Id, zone.Name, zone.Description, zone.Channel, zone.IsEnabled, controlService.IsStarted(zone.Channel))); }
public IActionResult Post([FromBody] CreateZoneModel model) { var zone = model.ToZone(); var id = _zoneRepository.Add(zone); return(Ok(id)); }
public Zone Add(Zone zone) { if (zone.Settings == null) { zone.Settings = new ZoneSettings(); } var newZone = _zoneRepository.Add(zone); return(newZone); }
public async Task <IActionResult> ExecuteAsync(SaveZone saveZone, CancellationToken cancellationToken) { var listZone = await zoneRepository.GetZoneCountryId(saveZone.CountryId, cancellationToken); var selectZone = listZone.SingleOrDefault(x => x.Title == saveZone.Title || x.Code == saveZone.Code); if (selectZone != null) { return(new NoContentResult()); } var zone = saveZoneToZoneMapper.Map(saveZone); // add created by //var user = _httpContextAccessor.HttpContext.User; //if (user == null) // return new NotFoundResult(); //var claims = user.Claims.ToList(); //if (claims.Count < 1) // return new NotFoundResult(); //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub").Value; //if (zone.CreatedBy == null) // zone.CreatedBy = userId; //zone.ModifiedBy = userId; // end created by zone = await zoneRepository.Add(zone, cancellationToken); var zoneViewModel = zoneToZoneMapper.Map(zone); return(new CreatedAtRouteResult( ZonesControllerRoute.GetZone, new { zoneId = zoneViewModel.Id }, zoneViewModel)); }
public void CreateZone(ZoneViewModel ZoneViewModel) { zoneRepository.Add(Mapper.Map <ZoneViewModel, Zone>(ZoneViewModel)); }