Beispiel #1
0
        public async Task <IActionResult> PutPhotographyVendor(int id, [FromForm] PhotographyVendor photographyVendor)
        {
            if (id != photographyVendor.CompanyID)
            {
                return(BadRequest());
            }

            if (photographyVendor.ImageFile != null)
            {
                DeleteImage(photographyVendor.ImageName);
                photographyVendor.ImageName = await SaveImage(photographyVendor.ImageFile);
            }

            _context.Entry(photographyVendor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhotographyVendorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <PhotographyVendor> > PostPhotographyVendor([FromForm] PhotographyVendor photographyVendor)
        {
            photographyVendor.ImageName = await SaveImage(photographyVendor.ImageFile);

            _context.Photographers.Add(photographyVendor);
            await _context.SaveChangesAsync();

            return(StatusCode(201));
        }