public Link UpdateLink(Link link)
        {
            var entry = _context.Entry(link);

            entry.State = EntityState.Modified;

            _context.SaveChanges();

            return(link);
        }
Пример #2
0
        public void UpdateProjectDescription(Project project)
        {
            _context.Projects.Attach(project);
            var entry = _context.Entry(project);

            entry.Property(e => e.FullDescription).IsModified  = true;
            entry.Property(e => e.ShortDescription).IsModified = true;
            entry.Property(e => e.Status).IsModified           = true;

            _context.SaveChanges();
        }
Пример #3
0
        public void RemoveAvatarByUserId(int userId)
        {
            var userAvatar = GetAvatarByUserId(userId);

            if (userAvatar != null)
            {
                var entry = _context.Entry(userAvatar);
                entry.State = EntityState.Deleted;

                _context.SaveChanges();
            }
        }
Пример #4
0
        /// <summary>
        /// Attaches the given entities list to the context underlying the set
        /// and updates changed fields in appropriate database entities
        /// that searches by the primary key value or adds new record to
        /// the database context if key value is absent.
        ///
        /// </summary>
        /// <param name="universitiesToUpdate">Entities list to update universities information.</param>
        /// <returns>Updated entities list if exists or null.</returns>
        public List <University> UpdateUniversities(List <University> universitiesToUpdate)
        {
            foreach (var university in universitiesToUpdate)
            {
                if (university.Id == 0)
                {
                    _context.Universities.Add(university);
                }
                else
                {
                    _context.Entry(university).State = EntityState.Modified;
                }
            }

            _context.SaveChanges();

            return(universitiesToUpdate);
        }
        public List <Language> UpdateLanguages(List <Language> languages)
        {
            foreach (var language in languages)
            {
                if (language.Id == 0)
                {
                    _context.Languages.Add(language);
                }
                else
                {
                    _context.Entry(language).State = EntityState.Modified;
                }
            }

            _context.SaveChanges();

            return(languages);
        }
Пример #6
0
        public List <SoftSkill> UpdateSoftSkills(List <SoftSkill> softSkills)
        {
            foreach (var softSkill in softSkills)
            {
                if (softSkill.Id == 0)
                {
                    _context.SoftSkills.Add(softSkill);
                }
                else
                {
                    _context.Entry(softSkill).State = EntityState.Modified;
                }
            }

            _context.SaveChanges();

            return(softSkills);
        }
Пример #7
0
        /// <summary>
        /// Attaches the given entities list to the context underlying the set
        /// and updates changed fields in appropriate database entities
        /// that searches by the primary key value or adds new record to
        /// the database context if key value is absent.
        ///
        /// </summary>
        /// <param name="coursesToUpdate">Entities list to update courses information.</param>
        /// <returns>Updated entities list if exists or null.</returns>
        public List <Course> UpdateCourses(List <Course> coursesToUpdate)
        {
            foreach (var course in coursesToUpdate)
            {
                if (course.Id == 0)
                {
                    _context.Courses.Add(course);
                }
                else
                {
                    _context.Entry(course).State = EntityState.Modified;
                }
            }

            _context.SaveChanges();

            return(coursesToUpdate);
        }
Пример #8
0
        public void UpdateGroupDescription(Group group)
        {
            _context.Groups.Attach(group);
            var entry = _context.Entry(group);

            entry.Property(e => e.TeamPurpose).IsModified         = true;
            entry.Property(e => e.TeamworkDescription).IsModified = true;

            _context.SaveChanges();
        }
        public void RemoveFile(int id)
        {
            var file = new File {
                Id = id
            };

            var entry = _context.Entry(file);

            entry.State = EntityState.Deleted;

            _context.SaveChanges();
        }
        /// <summary>
        /// Attaches the given entity to the context underlying the set
        /// and updates changed fields in appropriate database entity
        /// that searches by the primary key value.
        /// </summary>
        /// <param name="profileToUpdate">Entity to update qualification information. Id must be declared.</param>
        /// <returns>Updated entity if exists or null.</returns>
        public TraineeProfile UpdateQualification(TraineeProfile profileToUpdate)
        {
            if (profileToUpdate != null)
            {
                _context.TraineeProfiles.Attach(profileToUpdate);

                var entry = _context.Entry(profileToUpdate);
                entry.Property(p => p.Strengths).IsModified  = true;
                entry.Property(p => p.Weaknesses).IsModified = true;

                _context.SaveChanges();
            }

            return(profileToUpdate);
        }
Пример #11
0
        public Mentor Update(Mentor mentor)
        {
            if (mentor == null)
            {
                return(null);
            }

            var updatedUser = _context.Users.Find(mentor.Id);

            updatedUser.FullName = mentor.User.FullName;
            updatedUser.Contacts = mentor.User.Contacts;
            _context.Entry(updatedUser.Contacts).State = EntityState.Modified;

            _context.SaveChanges();

            return(_context.Mentors.Find(mentor.Id));
        }