Esempio n. 1
0
        public async Task <IActionResult> PutCustomer(long id, Customer customer)
        {
            if (id != customer.Id)
            {
                return(BadRequest());
            }

            if (customer.Image != null)
            {
                var base64array = Convert.FromBase64String(customer.Image);
                var filePath    = _env.WebRootPath + $"/customers/{Guid.NewGuid()}.jpg";
                System.IO.File.WriteAllBytes(filePath, base64array);
                customer.Image = Path.GetFileName(filePath);
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutAbout(long id, About about)
        {
            if (id != about.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }