示例#1
0
        public void Update(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            var local = Dbset.Local.ToList();

            foreach (var efloc in local)
            {
                if (GetPropValue(efloc, "Id").Equals(GetPropValue(entity, "Id")))
                {
                    _dataContext.Entry(efloc).State = EntityState.Detached;
                }
            }
            Dbset.Attach(entity);
            _dataContext.Entry(entity).State = EntityState.Modified;
        }
示例#2
0
 public ActionResult Edit(Department department)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(department).State = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
示例#3
0
 public void SaveStudent(Student student)
 {
     using (var context = new ProjectDbContext())
     {
         context.Entry(student.Department).State = System.Data.Entity.EntityState.Unchanged;
         context.Students.Add(student);
         context.SaveChanges();
     }
 }
示例#4
0
        public void EmailConfirm(Guid id)
        {
            var mode  = _context.Users.Find(id);
            var model = mode;

            model.IsVerified = true;
            _context.Entry(mode).CurrentValues.SetValues(model);
            _context.SaveChanges();
        }
示例#5
0
 public ActionResult Edit([Bind(Include = "cat_id,cat_name,status,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "CategoryPostId,CategoryName")] CategoryPost categoryPost)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoryPost).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoryPost));
 }
 public ActionResult Edit([Bind(Include = "Id,Code,Name")] Departments departments)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departments).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(departments));
 }
 public ActionResult Edit([Bind(Include = "Id,Username,Password,UserRole")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
示例#9
0
 public ActionResult Edit([Bind(Include = "RoomId,RoomNo")] Room room)
 {
     if (ModelState.IsValid)
     {
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(room));
 }
示例#10
0
 public ActionResult Edit([Bind(Include = "DirectorId,DirectorName,ImageURL,DateOfBirth,NetWorth,Nationality,Education")] Director director)
 {
     if (ModelState.IsValid)
     {
         db.Entry(director).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(director));
 }
 public ActionResult Edit([Bind(Include = "CinemaId,CinemaName,ImageURL,FoundingDate,NetWorth,CEO,Rating")] Cinema cinema)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cinema).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cinema));
 }
示例#12
0
 public ActionResult Edit([Bind(Include = "cus_id,cus_name,email,password,phone,address,status,create_date")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Description,TimeSpentInMinutes")] TaskModel taskModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taskModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(taskModel));
 }
示例#14
0
 public ActionResult Edit([Bind(Include = "Id,Name,CodeName,Description,StartDate,EndDate,Duration,UploadFile,Status")] Projct projct)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projct).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(projct));
 }
示例#15
0
 public ActionResult Edit([Bind(Include = "Id,Title,Body,UserRoleAssignedTo")] Document document)
 {
     if (ModelState.IsValid)
     {
         db.Entry(document).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(document));
 }
示例#16
0
 public ActionResult Edit(Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
 public ActionResult Edit([Bind(Include = "pub_id,pub_name,Description")] Publisher publisher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(publisher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(publisher));
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "id,UniversityName,City,PostalCode,StreetAddress,Country")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult Edit([Bind(Include = "GradeId,GradeName")] Grade grade)
 {
     if (ModelState.IsValid)
     {
         db.Entry(grade).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(grade));
 }
示例#20
0
 public ActionResult Edit([Bind(Include = "ProjectId,ProjectName,StartDate,FinishDate")] Project project)
 {
     if (ModelState.IsValid)
     {
         db.Entry(project).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(project));
 }
示例#21
0
 public ActionResult Edit([Bind(Include = "DesignationId,TeacherDesignation")] Designation designation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(designation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(designation));
 }
示例#22
0
 public ActionResult Edit([Bind(Include = "SemesterId,SemesterName")] Semester semester)
 {
     if (ModelState.IsValid)
     {
         db.Entry(semester).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(semester));
 }
示例#23
0
 public ActionResult Edit([Bind(Include = "SubjectId,SubjectName")] Subject subject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(subject));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Email,Password,Department,Gender,Address")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
 public ActionResult Edit([Bind(Include = "DepartmentId,DepartmentName,DepartmentCode")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
示例#26
0
 public ActionResult Edit([Bind(Include = "DayId,Name")] Day day)
 {
     if (ModelState.IsValid)
     {
         db.Entry(day).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(day));
 }
 public ActionResult Edit([Bind(Include = "CompanyId,CompanyName,ImageURL,NetWorth,FoundingDate,Country,AnnualIncome")] Company company)
 {
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
示例#28
0
        public IActionResult EditArtist(Artist upload, IFormFile file)
        {
            if (file == null || file.Length < 0)
            {
                upload.ImagePath = upload.ImagePath;
            }
            else
            {
                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    file.CopyTo(stream);
                }
                upload.ImagePath = file.FileName;
            }

            _context.Entry(upload).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(RedirectToAction("ArtistList"));
        }
示例#29
0
 public ActionResult Edit([Bind(Include = "EnrollCourseId,RegistrationId,CourseId,EnrollDate,GradeName")] EnrollCourse enrollcourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrollcourse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseCode", enrollcourse.CourseId);
     return(View(enrollcourse));
 }
        public async Task <ActionResult> Edit([Bind(Include = "DepartmentId,DepartmentCode,DepartmentName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Entry(department).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(department));
        }