Beispiel #1
0
        public async Task <IHttpActionResult> PutChapter(int id, Chapter chapter)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutProducts(int id, Product products)
        {
            if (id != products.ProductId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PutLearningPractise([FromRoute] int id, [FromBody] LearningPractise learningPractise)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,IsActive")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Beispiel #5
0
 protected override Subject UpdateEntity(int key, Subject update)
 {
     if (!ctx.Subjects.Any(o => o.Id == key))
     {
         throw Helpers.ResourceNotFoundError(Request);
     }
     update.Id = key;
     ctx.Subjects.Attach(update);
     ctx.Entry(update).State = System.Data.Entity.EntityState.Modified;
     ctx.SaveChanges();
     return update;
 }
 public bool Update(Student originalStudent, Student updatedStudent)
 {
     _context.Entry(originalStudent).CurrentValues.SetValues(updatedStudent);
     return(true);
 }
Beispiel #7
0
 /// <summary>
 /// Inserta una entidad
 /// </summary>
 /// <param name="entity">Entidad que se va  insertar</param>
 public virtual void Insert(TEntity entity)
 {
     _context.Entry <TEntity>(entity).State = EntityState.Added;
     _dbSet.Add(entity);
 }
 public void Update(IEmployee employee)
 {
     _learningContext.Entry(employee).State = EntityState.Modified;
 }