Ejemplo n.º 1
0
        public ActionResult Edit(Artist item)
        {
            try
            {
                if (User.IsInRole("Admin"))
                {
                    if (ModelState.IsValid)
                    {
                        if (item.ArtistId > 0)
                        {
                            var updatedRecord = _repo.Update(item);
                            if (updatedRecord.ArtistId < 1)
                            {
                                return(RedirectToAction("Error404", "Home"));
                            }

                            return(RedirectToAction("Index", "Artists"));
                        }
                    }
                }

                return(RedirectToAction("Login", "Account"));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update(int id, [FromBody] ArtistToCreateDto artistDto)
        {
            var mappedArtist = _mapper.Map <Artist>(artistDto);

            _artistRepo.Update(id, mappedArtist);

            await _artistRepo.SaveChangesAsync();

            var updatedArtist = await _artistRepo.GetByIdAsync(id);

            var mappedUpdatedArtist = _mapper.Map <ArtistDto>(updatedArtist);

            return(Ok(_linkService.CreateLinks(mappedUpdatedArtist)));
        }
Ejemplo n.º 3
0
 public Artist UpdateArtist(List <string> parameteres)
 {
     return(_artistRepo.Update(new Artist(long.Parse(parameteres[0]), parameteres[1], parameteres[2])));
 }