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)); }
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)); }
public ActionResult Put(Guid id, WatchingTypeCreateDto dto) { var entity = _repository.Update(id, dto); return(Ok(entity)); }
public ActionResult Post([FromBody] WatchingTypeCreateDto dto) { var entity = _repository.Create(dto); return(Ok(entity)); }