public async Task <PhotoGallaryUser> UpdatePhotoGallaryUserAsync([FromForm] PhotoGallaryUser photoGallaryUser) { if (photoGallaryUser.ImageFile != null) { DeleteImage(photoGallaryUser.ImageName); photoGallaryUser.ImageName = await SaveImage(photoGallaryUser.ImageFile); } _context.Entry(photoGallaryUser).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhotoGallaryUserExists(photoGallaryUser.UserID)) { return(null); } else { throw; } } return(photoGallaryUser); }
public async Task <PhotoGallaryUser> CreatePhotoGallaryUserAsync([FromForm] PhotoGallaryUser photoGallaryUser) { photoGallaryUser.ImageName = await SaveImage(photoGallaryUser.ImageFile); _context.PhotoGallaryUser.Add(photoGallaryUser); await _context.SaveChangesAsync(); return(photoGallaryUser); }
public async Task <ActionResult <PhotoGallaryUser> > PostPhotoGallaryUser([FromForm] PhotoGallaryUser photoGallaryUser) { await _unitOfWork._photoGallaryRepo.CreatePhotoGallaryUserAsync(photoGallaryUser); return(StatusCode(201)); }
public async Task <IActionResult> PutPhotoGallaryUser([FromForm] PhotoGallaryUser photoGallaryUser) { await _unitOfWork._photoGallaryRepo.UpdatePhotoGallaryUserAsync(photoGallaryUser); return(NoContent()); }