public async Task <IHttpActionResult> Put(int id, [FromBody] AppMusic vM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await this.musicService.GetById(id); if (result == null) { return(NotFound()); } else { result.Description = vM.Description; result.UpdatedDate = System.DateTime.Now; var resultU = await this.musicService.Update(result); if (resultU != 1) { return(this.StatusCode(HttpStatusCode.BadRequest)); } return(this.Ok()); } }
public async Task <int> Create(AppMusic entity) { using (var rm = new RepositoryManager(new DiscothequeDbEntities())) { return(await rm.MusicRespository.Add(entity)); } }
public async Task <IHttpActionResult> Create([FromBody] AppMusic vM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dateTime = System.DateTime.Now; vM.CreatedBy = "Obtener Usuario Actual"; vM.CreatedDate = dateTime; vM.UpdatedDate = dateTime; var resultC = await this.musicService.Create(vM); if (resultC != 1) { return(this.StatusCode(HttpStatusCode.BadRequest)); } var result = this.CreatedAtRoute("GetEmployee", new { controller = "Employee", id = vM.Id }, vM); return(result); }