public async Task <IActionResult> DeletePhotos(PhotosDto photosDto) { var photos = _mapper.Map <Photos>(photosDto); await _repo.DeleteData(photos); return(Ok(photosDto)); }
public async Task <ActionResult <PhotosDto> > Put(int photoId, PhotosDto dto) { try { var oldPhoto = await _eventRepository.GetPhoto(photoId); if (oldPhoto == null) { return(NotFound($"Could not find Photo with id {photoId}")); } var newPhoto = _mapper.Map(dto, oldPhoto); _eventRepository.Update(newPhoto); if (await _eventRepository.Save()) { return(NoContent()); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public async Task <IActionResult> CreateDeoartment(PhotosDto photosDto) { // here will be the insert method var photos = _mapper.Map <Photos>(photosDto); await _repo.UpdateData(photos); return(Ok(photosDto)); }
public async Task <int> RemoveImage(PhotosDto model) { var result = 0; try { result = await DeleteEntityAsync(new { entityId = model.entityId, photoType = model.photoType }); return(result); } catch (Exception) { return(result); } }
public async Task <ActionResult <PhotosDto> > Post(PhotosDto dto) { try { var mappedEntity = _mapper.Map <Photos>(dto); _eventRepository.Add(mappedEntity); if (await _eventRepository.Save()) { var location = _linkGenerator.GetPathByAction("Get", "Photos", new { mappedEntity.Id }); return(Created(location, _mapper.Map <PhotosDto>(mappedEntity))); } } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.InnerException.Message)); } return(BadRequest()); }
public async Task <IActionResult> RemoveImageFromDB(PhotosDto model) { var result = 0; try { var photoPath = Path.GetFileName(model.photoPath); result = await _entityPhotos.RemoveImage(new PhotosDto { entityId = model.entityId, photoType = model.photoType, photoPath = model.photoPath }); await DeleteObjectNonVersionedBucketAsync(photoPath); if (result > 0) { return(Ok(new ApiResponse(Microsoft.AspNetCore.Http.StatusCodes.Status200OK, false, MessagesConstants.ImageDeletedSuccessfully, result))); } return(Ok(new ApiResponse(Microsoft.AspNetCore.Http.StatusCodes.Status200OK, true, MessagesConstants.ImageNotDeletedSuccessfully, result))); } catch (Exception ex) { HttpContext.RiseError(new Exception(string.Concat("API := (Image := RemoveImage)", ex.Message, " Stack Trace : ", ex.StackTrace, " Inner Exception : ", ex.InnerException))); return(Ok(someIssueInProcessing)); } }
public PhotosDto PostCancion(PhotosDto photos, bool faborito = false, bool inapropiado = false, bool noListar = false) { //Obtiene el idDel usuario por medio del token userInfo = new UserInfoModulo(HttpContext); var idUsuario = userInfo.GetIdUsuario(); var album = _context.Album.Where(a => a.IdUsuario == idUsuario && a.Id == photos.albumId).FirstOrDefault(); var cancion = _context.Cancion.Where(c => c.IdAlbum == album.IdAlbum && c.Id == photos.id).FirstOrDefault(); if (cancion == null) { cancion = new Cancion() { Faborito = faborito, IdAlbum = album.IdAlbum, Id = photos.id, Inapropiado = inapropiado, NoVolverListar = noListar }; _context.Cancion.Add(cancion); } else { cancion.Faborito = faborito; cancion.Inapropiado = inapropiado; cancion.NoVolverListar = noListar; } _context.SaveChanges(); photos.categoria = faborito ? 1 : (inapropiado ? -1 : (noListar ? -2 : 0)); return(photos); }