示例#1
0
        public async Task <IActionResult> PutDecorationVendor(int id, [FromForm] DecorationVendor decorationVendor)
        {
            if (id != decorationVendor.CompanyID)
            {
                return(BadRequest());
            }

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

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult <DecorationVendor> > PostDecorationVendor([FromForm] DecorationVendor decorationVendor)
        {
            decorationVendor.ImageName = await SaveImage(decorationVendor.ImageFile);

            _context.Decorators.Add(decorationVendor);
            await _context.SaveChangesAsync();

            return(StatusCode(201));
        }