// update
        public project update(int id, project project)
        {
            if (!(checkRight(main.Enums.rights.editProject)))
            {
                throw new serviceException("Bu projeyi update edemezsiniz");
            }
            if (_context.project.Where(x => x.name == project.name).Count() > 0)
            {
                throw new serviceException("Bu isim kullanılıyor.Lütfen başka bir isim deneyiniz");
            }
            var findedProject = get(project.id);

            if (findedProject == null)
            {
                throw new serviceException("Böyle bir proje bulunamadı");
            }
            _context.Entry(findedProject).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(findedProject);
        }
Example #2
0
        // update
        public user updateUser(int id, user user)
        {
            if (!(checkRight(main.Enums.rights.editUser)))
            {
                throw new serviceException("Bu kullanıcıyı güncelleme hakkınız ypktur.");
            }

            var findedUser = GetUser(user.id);

            if (findedUser == null)
            {
                throw new serviceException("kullancıı bulunamadı");
            }
            if (_context.users.Where(x => x.email == user.email).Count() > 0)
            {
                throw new serviceException("Bu kullancıı mevcut");
            }

            _context.Entry(findedUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(user);
        }