Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutPersonalDetail(int id, PersonalDetail personalDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != personalDetail.AutoId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public bool Delete(Trainee trainee)
        {
            TrainingDBContext db = new TrainingDBContext();

            db.Trainee.Attach(trainee);
            db.Entry(trainee).State = EntityState.Deleted;

            int rowAffected = db.SaveChanges();

            return(rowAffected > 0);
        }
Ejemplo n.º 3
0
        public Institution GetWithExistingTraineeById(int id)
        {
            TrainingDBContext db = new TrainingDBContext();
            var institution      = db.Institutions.FirstOrDefault(c => c.Id == id);

            db.Entry(institution)
            .Collection(c => c.Trainees)
            .Query()
            .Where(c => c.IsDeleted == false)
            .Load();

            return(institution);
        }
 public void Update(int id, T entity)
 {
     entity.Id = id;
     _trainingDBContext.Entry <T>(entity).State = System.Data.Entity.EntityState.Modified;
     _trainingDBContext.SaveChanges();
 }
Ejemplo n.º 5
0
 public void UpdateItem(T item)
 {
     Database.Entry(item).State = EntityState.Modified;
 }