Esempio n. 1
0
 private void SetUserModified(User user)
 {
     context.Entry(user).Property(u => u.Name).IsModified        = true;
     context.Entry(user).Property(u => u.Description).IsModified = true;
     context.Entry(user).Property(u => u.IsDisplayed).IsModified = true;
     context.Entry(user).Property(u => u.IsActive).IsModified    = true;
     context.Entry(user).Property(u => u.Email).IsModified       = true;
 }
Esempio n. 2
0
 private void SetModelForModification(Salon salon)
 {
     context.Entry(salon).Property(s => s.Name).IsModified        = true;
     context.Entry(salon).Property(s => s.Description).IsModified = true;
     context.Entry(salon).Property(s => s.ExtraInfo).IsModified   = true;
     context.Entry(salon).Property(s => s.IsActive).IsModified    = true;
     context.Entry(salon.Welcome).State = EntityState.Modified;
 }
Esempio n. 3
0
        public async Task <IActionResult> UpdateCategory([FromRoute] int id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != category.Id)
            {
                return(BadRequest());
            }

            try
            {
                context.Entry(category).Property(c => c.Name).IsModified = true;
                await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                if (!CategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
                }
            }

            return(NoContent());
        }
Esempio n. 4
0
        public async Task <IActionResult> PutOpenHour(int id, OpenHour openHour)
        {
            if (id != openHour.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }