public async Task <bool> UpdateDepartment(Guid?id, Department departmentToUpdate) { try { var dept = await _taskDB.Department.Where(e => e.RowId == id).FirstOrDefaultAsync(); if (dept != null) { dept.Name = departmentToUpdate.Name; dept.Description = departmentToUpdate.Description; dept.Address = departmentToUpdate.Address; _taskDB.Attach(dept); _taskDB.Entry(dept).Property(e => e.Name).IsModified = true; _taskDB.Entry(dept).Property(e => e.Description).IsModified = true; _taskDB.Entry(dept).Property(e => e.Address).IsModified = true; await _taskDB.SaveChangesAsync(); return(true); } return(false); } catch { return(false); } }
public ActionResult Edit([Bind(Include = "ID,Title,Description,CreatedDate,DueDate,Tag,CurrentStatus,BoardID")] Task task) { if (ModelState.IsValid) { db.Entry(task).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); return(RedirectToAction("Details", "Boards", new { id = task.BoardID })); } return(View(task)); }
public async Task <IActionResult> PutProject(int id, Project project) { if (id != project.Id) { return(BadRequest()); } _context.Entry(project).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit(TaskItem taskitem) { if (ModelState.IsValid) { db.Entry(taskitem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taskitem)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Board board) { if (ModelState.IsValid) { db.Entry(board).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(board)); }
public async Task <bool> UpdateUser(Guid?id, User userToUpdate) { try { var user = await _taskDB.User.Where(e => e.RowId == id).FirstOrDefaultAsync(); if (user != null) { user.FirstName = userToUpdate.FirstName; user.LastName = userToUpdate.LastName; user.Address = userToUpdate.Address; user.Country = userToUpdate.Country; user.Description = userToUpdate.Description; user.RDepartment = userToUpdate.RDepartment; _taskDB.Attach(user); _taskDB.Entry(user).Property(e => e.FirstName).IsModified = true; _taskDB.Entry(user).Property(e => e.LastName).IsModified = true; _taskDB.Entry(user).Property(e => e.Address).IsModified = true; _taskDB.Entry(user).Property(e => e.Country).IsModified = true; _taskDB.Entry(user).Property(e => e.Description).IsModified = true; _taskDB.Entry(user).Property(e => e.RDepartment).IsModified = true; await _taskDB.SaveChangesAsync(); return(true); } return(false); } catch { return(false); } }
public ActionResult EditPost(int Id)// TaskItem taskitem) { var taskitem = db.Tasks.First(t => t.Id == Id); if (ModelState.IsValid) { bool isVupdated = TryUpdateModel(taskitem); db.Entry(taskitem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taskitem)); }
public ActionResult Edit(Job job) { int id = job.Id; using (var db = new TaskDBContext()) { if (ModelState.IsValid) { db.Entry(job).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction($"getbyid/{job.Id}")); } }
public async Task <OperationResult> UpdateAsync(int key, City entityToUpdate) { var selectedCity = await _context.Cities.FindAsync(key); if (selectedCity != null) { var updatedCity = _mapper.Map <Entities.City>(entityToUpdate); updatedCity.Id = key; updatedCity.ModifiedAt = DateTime.Now; _context.Entry(updatedCity).State = EntityState.Modified; await _context.SaveChangesAsync(); return(OperationResult.Succeeded()); } return(OperationResult.NotFound()); }
public ActionResult Edit(Task task, bool sendEmail) { if (ModelState.IsValid) { if (sendEmail) { Utilities.SendEmail(task.Who, task.TaskName, task.TaskDescription); } task.Priority = Convert.ToInt32(Request.Form["rating"]); task.Date = DateTime.Now; db.Entry(task).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(task)); }
public ActionResult Update(Task t) { try { _taskDbContext.Entry(t).State = EntityState.Modified; _taskDbContext.SaveChanges(); return(Ok(new { Status = 1, Message = "Task updated" })); } catch (Exception ex) { return(Ok(new { Status = 0, Message = "Failed to update task", Detail = ex.Message })); } }
public async Task <IActionResult> PutTask(int id, Models.Task task) { task.id = id; _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void UpdateExistingTask(Task task) { _db.Entry(task).State = EntityState.Modified; _db.SaveChanges(); }