public async Task <IActionResult> Edit(int id, [Bind("StudentId,Name,Surname,Middilname,Logn,Password,Course,DirectionId")] Student student) { if (id != student.StudentId) { return(NotFound()); } if (ModelState.IsValid) { try { student.GrupName = grupName; _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.StudentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DirectionName"] = new SelectList(_context.Directions, "DirectionId", "Name"); return(View(student)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] SubjectBlockType subjectBlockType) { if (id != subjectBlockType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subjectBlockType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectBlockTypeExists(subjectBlockType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(subjectBlockType)); }
public async Task <IActionResult> Edit(int id, [Bind("FacultetID,Name")] Facultet facultet) { if (id != facultet.FacultetID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(facultet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FacultetExists(facultet.FacultetID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Create))); } return(View(facultet)); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Phone,Email,Id")] Supplier supplier) { if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault()) { supplier.RecordCreateTime = DateTime.Now; if (id != supplier.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(supplier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(supplier.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(supplier)); } return(RedirectToAction("Logout", "Login")); }
public async Task <IActionResult> Edit(int id, [Bind("TeacherId,Name,Surname,Middilname,Position,AcademicDegree,DepartmentId")] Teacher teacher) { if (id != teacher.TeacherId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(teacher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeacherExists(teacher.TeacherId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentName"] = new SelectList(_context.Departments, "DepartmentId", "Name"); return(View(teacher)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TaskName,StartDate,EndDate")] DataModelEntity.Entity.Task task, [Bind("type")] string type) { if (id != task.Id) { return(NotFound()); } if (ModelState.IsValid) { try { task.TaskType = type; _context.Update(task); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(task.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(task)); }
public async Task <IActionResult> Edit(int id, [Bind("SubjectId,SubjectCode,Name,Lecture,Practical,Laboratory,Seminar,CourseWork,SubjectBlockTypeId,IndependentEducation,OneOne,OneTwo,TwoOne,TwoTwo,ThreeOne,ThreeTwe,FourOne,FourTwo,KOneOne,KOneTwo,KTwoOne,KTwoTwo,KThreeOne,KThreeTwe,KFourOne,KFourTwo")] Subject subject) { if (id != subject.SubjectId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectExists(subject.SubjectId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SubjectBlock"] = new SelectList(_context.SubjectBlockTypes, "Id", "Name"); return(View(subject)); }
public async Task <IActionResult> Edit(int id, [Bind("DepartmentId,Name,FacultetId")] Department department) { if (id != department.DepartmentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.DepartmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Create))); } ViewData["FacultetName"] = new SelectList(_context.Facultets, "FacultetID", "Name"); return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("DirectionId,Code,Name")] Direction direction) { if (id != direction.DirectionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(direction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DirectionExists(direction.DirectionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(direction)); }
public async Task <IActionResult> Edit(int id, [Bind("HarvestPlanId,Name,DepatmentId,TeacherId,GrupId")] HarvestPlan harvestPlan) { if (id != harvestPlan.HarvestPlanId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(harvestPlan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HarvestPlanExists(harvestPlan.HarvestPlanId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TeacherId"] = new SelectList(_context.Teachers, "TeacherId", "FullName", harvestPlan.TeacherId); ViewData["GrupId"] = new SelectList(_context.Grups, "GrupId", "Name", harvestPlan.GrupId); return(View(harvestPlan)); }
public async Task <IActionResult> Select(int?Id) { if (Current.GrupId != 0) { var student = _context.Students.Find(Id); if (student != null && Current != null) { student.GrupName = Current.Name; _context.Update(student); await _context.SaveChangesAsync(); } } Select(); SearchContent(Current); return(View("Edit", Current)); }
public async Task <IActionResult> Login(string values) { UserInfo model = Newtonsoft.Json.JsonConvert.DeserializeObject <UserInfo>(values); var userIdentity = new Models.Dtos.Identity.UserIdentity(); var entity = await _db.UserInfo.FirstOrDefaultAsync(c => (c.Phone == model.Phone || c.UserName == model.UserName) && c.UserPassword == model.UserPassword); if (entity != null) { entity.LastLoginTime = DateTime.Now; _db.Update(entity); _db.SaveChanges(); } return(Json(entity)); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Surname,rlt_Department_Id,Position,Password,Phone,Email,Id")] User user) { if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault()) { user.RecordCreateTime = DateTime.Now; if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(UserList))); } ViewData["rlt_Department_Id"] = new SelectList(_context.Departments, "Id", "Name", user.rlt_Department_Id); return(View(user)); } return(RedirectToAction("Logout", "Login")); }
public async Task <IActionResult> Edit(int id, [Bind("Information,ItemGivenTime,rlt_User_Id,rlt_Item_Id,Id,RecordCreateTime")] Allocation allocation) { if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault()) { if (id != allocation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(allocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AllocationExists(allocation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["rlt_Item_Id"] = new SelectList(_context.Items, "Id", "Id", allocation.rlt_Item_Id); ViewData["rlt_User_Id"] = new SelectList(_context.Users, "Id", "Id", allocation.rlt_User_Id); return(View(allocation)); } return(RedirectToAction("Logout", "Login")); }
public void Update_SetsEntityState_ToModified() { using (var dbContext = new EntityDbContext()) { var permissionName = Guid.NewGuid().ToString(); var entity = new Permission { Name = permissionName, Description = "d1" }; dbContext.Create(entity); var affectedRows = dbContext.SaveChangesAsync().Result; affectedRows.ShouldEqual(1); dbContext.Entry(entity).State.ShouldEqual(EntityState.Unchanged); dbContext.Update(entity); dbContext.Entry(entity).State.ShouldEqual(EntityState.Modified); } }
protected override void UpdateDummyModel(DummyModel entity, DummyModel dto, EntityDbContext entityDbContext) { entityDbContext.Update(dto); }