Beispiel #1
0
        public WatchingTypeConfirmationDto Create(WatchingTypeCreateDto dto)
        {
            WatchingType newWatchingType = new WatchingType()
            {
                Id   = Guid.NewGuid(),
                Type = dto.Type
            };

            _db.WatchingTypes.Add(newWatchingType);

            _db.SaveChanges();

            _logger.Log("Create WatchingType!");

            return(_mapper.Map <WatchingTypeConfirmationDto>(newWatchingType));
        }
Beispiel #2
0
        public WatchingTypeConfirmationDto Update(Guid id, WatchingTypeCreateDto dto)
        {
            var WatchingType = _db.WatchingTypes.FirstOrDefault(e => e.Id == id);

            if (WatchingType == null)
            {
                throw new UserException("WatchingType does not exist");
            }

            WatchingType.Type = dto.Type;

            _db.SaveChanges();

            _logger.Log("Update WatchingType!");

            return(_mapper.Map <WatchingTypeConfirmationDto>(WatchingType));
        }
Beispiel #3
0
        public ActionResult Put(Guid id, WatchingTypeCreateDto dto)
        {
            var entity = _repository.Update(id, dto);

            return(Ok(entity));
        }
Beispiel #4
0
        public ActionResult Post([FromBody] WatchingTypeCreateDto dto)
        {
            var entity = _repository.Create(dto);

            return(Ok(entity));
        }