public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ProductId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutSalesPerson([FromRoute] int id, [FromBody] SalesPerson salesPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != salesPerson.BusinessEntityId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "Id,Position,Company,StartDate,EndDate,Description")] Experience experience)
 {
     if (ModelState.IsValid)
     {
         db.Entry(experience).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(experience));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "Id")] Skills skills)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skills).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skills));
 }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Id,University,Degree,Description,GPA")] Education education)
 {
     if (ModelState.IsValid)
     {
         db.Entry(education).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(education));
 }
 public ActionResult Edit([Bind(Include = "Id,Description")] Interests interests)
 {
     if (ModelState.IsValid)
     {
         db.Entry(interests).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(interests));
 }
 public ActionResult Edit([Bind(Include = "Id,Adress,Phone,Email,Description,LinkedinLink,FacebookLink,GithubLink,TwitterLink")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
Ejemplo n.º 9
0
        public void addTasks(List <Task> tasks)
        {
            foreach (var item in tasks)
            {
                var exits = taskEntity.Where(c => c.TaskName == item.TaskName).FirstOrDefault();

                if (exits == null)
                {
                    context.Entry(item).State = EntityState.Added;
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,Description")] Award award)
 {
     if (Session["Login"] == null || (bool)Session["Login"] == false)
     {
         return(RedirectToAction("Login", "Login"));
     }
     ;
     if (ModelState.IsValid)
     {
         db.Entry(award).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(award));
 }
Ejemplo n.º 11
0
        public Employee AddEmployee(Employee employee)
        {
            var dbEmployee = new Employee();

            var exits = employeesEntity.Where(c => c.EmployeeNumber == employee.EmployeeNumber).FirstOrDefault();

            if (exits == null)
            {
                context.Entry(employee).State = EntityState.Added;
                context.SaveChanges();
                dbEmployee = employee;
            }
            else
            {
                dbEmployee = exits;
            }

            return(dbEmployee);
        }