public void Delete(int taskId) { var appTask = new AppTask { Id = taskId }; _dbContext.Entry(appTask).State = EntityState.Deleted; _dbContext.SaveChanges(); }
public void Update(T entity) { _context.Set <T>().Attach(entity); var entry = _context.Entry(entity); entry.State = EntityState.Modified; _context.SaveChanges(); }
public ActionResult Edit([Bind(Include = "CustomerId,CompanyName,Phone,Address,Email")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "ProjectId,CustomerId,Name,Description,PlannedStartingDate,PlannedEndingDate,StartingDate,EndingDate")] Project project) { if (ModelState.IsValid) { db.Entry(project).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerId = new SelectList(db.Customer, "CustomerId", "CompanyName", project.CustomerId); return(View(project)); }
public ActionResult Create([Bind(Include = "EmployeeId,FirstName,LastName,Email,Address,IdentityNumber,DateOfBirth,HiringDate")] Employee employee) { if (ModelState.IsValid) { var typeOfUser = GetUserType(); var obj = Activator.CreateInstance(typeOfUser); FillEmployeeProperties(obj as Employee, employee); if (obj != null) { db.Entry(obj).State = EntityState.Added; db.SaveChanges(); } } return(RedirectToAction("Index")); }
public async Task <T> UpdateAsync(T entity, params Expression <Func <T, object> >[] includeProperties) { var dbEntry = _dbContext.Entry(entity); foreach (var includeProperty in includeProperties) { dbEntry.Property(includeProperty).IsModified = true; } await _dbContext.SaveChangesAsync(); return(entity); }
public ActionResult Edit([Bind(Include = "CustomerDemandId,CustomerId,Demand,DemandType")] CustomerDemand customerDemand) { if (ModelState.IsValid) { db.Entry(customerDemand).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectId = new SelectList(db.Project, "ProjectId", "Name", customerDemand.ProjectId); return(View(customerDemand)); }
public ActionResult Edit([Bind(Include = "EmployeeId,TaskId,ProjectId,Name,Description,CreationDate,StartingDate,EndingDate,Status")] Task task) { if (ModelState.IsValid) { db.Entry(task).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectId = new SelectList(db.Project, "ProjectId", "Name", task.ProjectId); return(View(task)); }
public virtual void SetNull(TEntity entity, string propertyName) => _context.Entry(entity).Property(propertyName).CurrentValue = null;
public void UpdateQuest(CreateQuest task) { _context.Entry(task).State = EntityState.Modified; }