Exemple #1
0
        public void Delete(int id)
        {
            ATPEntities context = new ATPEntities();

            context.CV.Remove(context.CV.FirstOrDefault(element => element.ID == id));
            context.SaveChanges();
        }
Exemple #2
0
        //Insert a user to the database
        public void Insert(UserDTO user)
        {
            ATPEntities _dbContext = new ATPEntities(); //Database context(database connection)

            _dbContext.USER_NEW_NEW.Add(Convert(user)); //Map DTO to Database Object
            _dbContext.SaveChanges();                   //ALWAYS SAVE AFTER BEING DONE. Make only one transfer to the database for safety reasons
        }//Adds a user to the database
Exemple #3
0
        public void Insert(CVDTO dto)
        {
            ATPEntities context = new ATPEntities();

            context.CV.Add(Convert(dto));
            context.SaveChanges();
        }
Exemple #4
0
        }//Adds a box to the database

        public void Delete(int id)
        {
            ATPEntities _dbContext = new ATPEntities();//Create connection

            //Remove box if it exists
            _dbContext.BOX.Remove(_dbContext.BOX.Where(entity => entity.ID == id).FirstOrDefault());
            _dbContext.SaveChanges();//Save Changes to the database
        }//Removes a box with the specified ID
Exemple #5
0
        public void Insert(BoxDTO box)
        {
            ATPEntities _dbContext = new ATPEntities(); //Create connection

            _dbContext.BOX.Add(Convert(box));           //Add box to database

            _dbContext.SaveChanges();                   //Save Changes to the database
        }//Adds a box to the database
Exemple #6
0
        }//Get a user by a specified ID

        public void Delete(int id)
        {
            ATPEntities _dbContext = new ATPEntities(); //Database context(database connection)

            //Remove user if there exists one with the specified username
            _dbContext.USER_NEW_NEW.Remove(_dbContext.USER_NEW_NEW.FirstOrDefault(user => user.ID == id));
            _dbContext.SaveChanges();//ALWAYS SAVE AFTER BEING DONE. Make only one transfer to the database for safety reasons
        }//Delete a user by a specified ID
Exemple #7
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
Exemple #8
0
        }//Delete a user by a specified ID

        public void Edit(UserDTO dto)
        {
            ATPEntities  _dbContext = new ATPEntities(); //Database context(database connection)
            USER_NEW_NEW userOld    = _dbContext.USER_NEW_NEW.FirstOrDefault(user => user.USERNAME == dto.Username);
            USER_NEW_NEW userNew    = Convert(dto);

            //Map values from new entity to the existing version because this is how it must be done
            foreach (PropertyInfo property in userOld.GetType().GetProperties())
            {
                property.SetValue(userOld, property.GetValue(userNew));
            }
            _dbContext.SaveChanges();//ALWAYS SAVE AFTER BEING DONE. Make only one transfer to the database for safety reasons
        }//Edit a user by a specified from the DTO ID
Exemple #9
0
        public void Edit(CVDTO dto)
        {
            ATPEntities context = new ATPEntities();
            CV          entity  = context.CV.FirstOrDefault(element => element.ID == dto.ID);

            entity.Address     = dto.Address;
            entity.Education   = dto.Education;
            entity.Email       = dto.Email;
            entity.Experience  = dto.Experience;
            entity.FirstName   = dto.FirstName;
            entity.ID          = dto.ID;
            entity.LastName    = dto.LastName;
            entity.Qualities   = dto.Qualities;
            entity.Picture     = dto.PictureBytes;
            entity.PictureName = dto.PictureName;
            context.SaveChanges();
        }