Пример #1
0
        public async Task <IActionResult> PutProductIncoms(int id, ProductIncoms productIncoms)
        {
            if (id != productIncoms.Id || !ModelState.IsValid)
            {
                return(BadRequest());
            }
            _context.Entry(productIncoms).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutUnits(int id, Units units)
        {
            if (units.Id != id || !ModelState.IsValid)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UnitsExists(units.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public async Task <IActionResult> PutTech(int id, Tech tech)
        {
            if (id != tech.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #4
0
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.Id && id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value) || !ModelState.IsValid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #5
0
        public async Task <int> Register(Users user)
        {
            await _context.Users.AddAsync(user);

            await _context.SaveChangesAsync();

            return(user.Id);
        }
Пример #6
0
 public virtual async Task <int> AddAsync(TEntity entity)
 {
     _dbset.Add(entity);
     return(await _dbContext.SaveChangesAsync());
 }