public async Task <IActionResult> PutFileUpload(int id, FileUpload fileUpload)
        {
            if (id != fileUpload.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Exemplo n.º 3
0
        public IHttpActionResult Putmessage(int id, message message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != message.msgID)
            {
                return(BadRequest());
            }

            db.Entry(message).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!messageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutSessionTypes(int id, SessionTypes sessionTypes)
        {
            if (id != sessionTypes.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.Id)
            {
                return(BadRequest());
            }

            //have to do password hash and stuff

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

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

            return(NoContent());
        }
Exemplo n.º 6
0
        public IHttpActionResult PutTestDB(int id, TestDB testDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != testDB.ID)
            {
                return(BadRequest());
            }

            db.Entry(testDB).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestDBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutUserDetails(int id, UserDetails userDetails)
        {
            if (id != userDetails.UserId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Id,TestCode,TestName,Description,Charges")] Test test)
 {
     if (ModelState.IsValid)
     {
         db.Entry(test).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(test));
 }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,Cidade,Estado,País")] Table table)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table));
 }
Exemplo n.º 10
0
        public async Task <IActionResult> PutTodoItem(int id, TodoItem item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id != null)
            {
                TestCase testCase = new TestCase {
                    Id = id.Value
                };
                db.Entry(testCase).State = EntityState.Deleted;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(NotFound());
        }
Exemplo n.º 12
0
        public async Task UpdateEmployee(Employee employee)
        {
            _context.Entry(employee).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(employee.Id))
                {
                    throw new NotFoundException();
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 13
0
        public void Update(Product product)
        {
            try
            {
                Product productToUpdate = GetAllProducts().Where(x => x.ProductCategoryID == product.ProductCategoryID).FirstOrDefault();

                if (productToUpdate != null)
                {
                    productToUpdate.Name      = product.Name;
                    productToUpdate.ValidFrom = product.ValidFrom;
                    productToUpdate.Quantity  = product.Quantity;
                    productToUpdate.Price     = product.Price;

                    testDBContext.Products.Attach(productToUpdate);
                    testDBContext.Entry(productToUpdate).State = EntityState.Modified;
                    testDBContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
 public void Update(T entity)
 {
     _dbSet.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }