Exemplo n.º 1
0
        }//Removes a box with the specified ID

        public void Edit(BoxDTO dto)
        {
            ATPEntities _dbContext = new ATPEntities();                                                    //Create connection
            BOX         old        = _dbContext.BOX.Where(entity => entity.ID == dto.ID).FirstOrDefault(); //Get the old box
            BOX         newBOX     = Convert(dto);                                                         //Create a new box from a conversion

            foreach (PropertyInfo property in old.GetType().GetProperties().Where(property => property.Name != "ID"))
            {
                property.SetValue(old, property.GetValue(newBOX)); // set the values of the old box to the values of the new one
            }
            _dbContext.SaveChanges();                              //Save Changes to the database
        }//Edit a box with the specified by the DTO ID