Example #1
0
        public Profile UpdateProfile(Profile profile)
        {
            var id = _profilecontext.Profiles.First(x => x.UserId.ToString() == _info.Id).Id;

            profile.UserId = Guid.Parse(_info.Id);
            profile.Id     = id;
            _profilecontext.ChangeTracker.Entries().ElementAt(0).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
            _profilecontext.SaveChanges();
            _profilecontext.Attach(profile);
            _profilecontext.Entry(profile).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _profilecontext.SaveChanges();

            return(profile);
        }
Example #2
0
        public Request UpdateRequest(Request request)
        {
            request.UserId = Guid.Parse(_info.Id);
            var userid = _requestcontext.Requests.First(x => x.Id == request.Id).UserId;

            if (userid.ToString() == _info.Id)
            {
                var lst = _requestcontext.ChangeTracker.Entries().ElementAt(0).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
                _requestcontext.Attach(request);
                _requestcontext.Entry(request).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _requestcontext.SaveChanges();
            }

            return(request);
        }
Example #3
0
        public Project UpdateProject(Project project)
        {
            project.UserId = Guid.Parse(_info.Id);
            var userid = _projectcontext.Projects.First(x => x.Id == project.Id).UserId;

            if (userid.ToString() == _info.Id)
            {
                var lst = _projectcontext.ChangeTracker.Entries().ElementAt(0).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
                _projectcontext.Attach(project);
                _projectcontext.Entry(project).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _projectcontext.SaveChanges();
            }

            return(project);
        }