示例#1
0
        public async Task <ActionResult <Celeb> > Put(string id, [FromBody] Celeb value)
        {
            if (!this.db.Celebs.TryGetValue(id, out _))
            {
                return(NotFound());
            }

            var entity = this.db.Celebs[id] = value.ToEntity(id);

            await this.db.CommitAsync();

            return(entity.AsDTO());
        }
示例#2
0
        public async Task <ActionResult> Post([FromBody] Celeb celeb)
        {
            try
            {
                this.db.Celebs.Add(celeb.Id, celeb.ToEntity());
                await this.db.CommitAsync();

                return(Ok());
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
        }