Exemplo n.º 1
0
        public IHttpActionResult Put(int id, EntryDto entryDto)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);
                
            _entriesRepository.Update(entryDto.ToModel());

            return StatusCode(System.Net.HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
 public IHttpActionResult Put(int id, EntryDto entry)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _entriesRepository.Add(entry.ToModel());
     return(StatusCode(System.Net.HttpStatusCode.NoContent));
 }
Exemplo n.º 3
0
        public IHttpActionResult Put(int id, EntryDto entryDto)
        {
            ValidateEntry(entryDto);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var entryModel = entryDto.ToModel();

            _entriesRepository.Update(entryModel);

            return(StatusCode(System.Net.HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
        public IHttpActionResult Post(EntryDto entry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var entryModel = entry.ToModel();

            _entriesRepository.Add(entryModel);
            return(Created(
                       Url.Link("DefaultApi", new { controller = "Entries", id = entry.Id }), entry));
        }
Exemplo n.º 5
0
        public IHttpActionResult Post(EntryDto entryDto)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            var entry = entryDto.ToModel();
            _entriesRepository.Add(entry);

            entryDto.Id = entry.Id;

            return Created(
                Url.Link(WebApiConfig.DefaultApiName, new { controller = "Entries", id = entryDto.Id }),
                entryDto);
        }