public WatchingConfirmationDto Create(WatchingCreateDto dto)
        {
            Watching newWatching = new Watching()
            {
                Id        = Guid.NewGuid(),
                WatchedId = dto.WatchedId,
                WatcherId = dto.WatcherId
            };

            _db.Watchings.Add(newWatching);

            _db.SaveChanges();

            _logger.Log("Create Watching!");

            return(_mapper.Map <WatchingConfirmationDto>(newWatching));
        }
        public WatchingConfirmationDto Update(Guid id, WatchingCreateDto dto)
        {
            var watching = _db.Watchings.FirstOrDefault(e => e.Id == id);

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

            watching.WatchedId = dto.WatchedId;
            watching.WatcherId = dto.WatcherId;

            _db.SaveChanges();

            _logger.Log("Update Watching!");

            return(_mapper.Map <WatchingConfirmationDto>(watching));
        }
コード例 #3
0
        public ActionResult Put(Guid id, WatchingCreateDto dto)
        {
            var entity = _repository.Update(id, dto);

            return(Ok(entity));
        }
コード例 #4
0
        public ActionResult Post([FromBody] WatchingCreateDto dto)
        {
            var entity = _repository.Create(dto);

            return(Ok(entity));
        }