Exemple #1
0
        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);
        }
Exemple #2
0
        public async Task <PhotoGallaryUser> CreatePhotoGallaryUserAsync([FromForm] PhotoGallaryUser photoGallaryUser)
        {
            photoGallaryUser.ImageName = await SaveImage(photoGallaryUser.ImageFile);

            _context.PhotoGallaryUser.Add(photoGallaryUser);
            await _context.SaveChangesAsync();

            return(photoGallaryUser);
        }
Exemple #3
0
        public async Task <ActionResult <PhotoGallaryUser> > PostPhotoGallaryUser([FromForm] PhotoGallaryUser photoGallaryUser)
        {
            await _unitOfWork._photoGallaryRepo.CreatePhotoGallaryUserAsync(photoGallaryUser);

            return(StatusCode(201));
        }
Exemple #4
0
        public async Task <IActionResult> PutPhotoGallaryUser([FromForm] PhotoGallaryUser photoGallaryUser)
        {
            await _unitOfWork._photoGallaryRepo.UpdatePhotoGallaryUserAsync(photoGallaryUser);

            return(NoContent());
        }