예제 #1
0
        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)));
        }
예제 #2
0
        public IActionResult Post([FromBody] CreateZoneModel model)
        {
            var zone = model.ToZone();

            var id = _zoneRepository.Add(zone);

            return(Ok(id));
        }
예제 #3
0
        public Zone Add(Zone zone)
        {
            if (zone.Settings == null)
            {
                zone.Settings = new ZoneSettings();
            }

            var newZone = _zoneRepository.Add(zone);

            return(newZone);
        }
예제 #4
0
        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));
        }
예제 #5
0
 public void CreateZone(ZoneViewModel ZoneViewModel)
 {
     zoneRepository.Add(Mapper.Map <ZoneViewModel, Zone>(ZoneViewModel));
 }