コード例 #1
0
        public IActionResult AddSubTask(EachTask newTask)
        {
            newTask.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (ModelState.IsValid) //changes parent class ID field to true
            {
                EachTask newParentTask = _context.Task.Find(newTask.ParentTaskId);
                newParentTask.Parent = true;

                _context.Entry(newParentTask).State = Microsoft.EntityFrameworkCore.EntityState.Modified;  //remember to copy paste this honkin thing
                _context.Update(newParentTask);
                _context.SaveChanges();
            }

            if (ModelState.IsValid)  //adds child class
            {
                _context.Task.Add(newTask);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "Id,UserId,Description,DueDate,TimeLeft,Complete")] Task task)
        {
            if (ModelState.IsValid)
            {
                db.Entry(task).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            HttpCookie userId = HttpContext.Request.Cookies[Constant.UserIdCookie];

            ViewBag.UserId = int.Parse(userId.Value);
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", task.UserId);
            return(View(task));
        }
コード例 #3
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public async Task <ActionResult <Tasks> > PutTask(int id, Tasks task)
        {
            if (id != task.Id)
            {
                return(BadRequest());
            }

            _context.Entry(task).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(task);
        }
コード例 #5
0
        public async Task <ActionResult <Categories> > PutCategories(int id, Categories categories)
        {
            if (id != categories.Id)
            {
                return(BadRequest());
            }

            _context.Entry(categories).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!CategoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest());
                }
            }

            return(categories);
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "Id,UserName,Email,Password,PasswordCheck")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Department,Username,Email,Password,ConfirmPassword")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #8
0
 public ActionResult Update([Bind(Include = "Id,IsDone")] Task task)
 {
     if (ModelState.IsValid)
     {
         db.Tasks.Attach(task);
         db.Entry(task).Property(t => t.IsDone).IsModified = true;
         db.Configuration.ValidateOnSaveEnabled            = false;
         db.SaveChanges();
         return(JsonSuccess(new { task = task }));
     }
     return(JsonError("Model is invalid"));
 }
コード例 #9
0
        public ActionResult Edit([Bind(Include = "Id,Description,DueDate,Completed,UserId")] Task task)
        {
            if (ModelState.IsValid)
            {
                db.Entry(task).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", task.UserId);

            return(View(task));
        }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "Id,Title,Content,Severity,DeadLine,CreatedAt")] Task task)
 {
     if (ModelState.IsValid)
     {
         task.UpdatedAt       = DateTime.Now;
         db.Entry(task).State = EntityState.Modified;
         db.SaveChanges();
         TempData["flash"] = "タスクを編集しました。";
         return(RedirectToAction("Index"));
     }
     return(View(task));
 }
コード例 #11
0
 public void Update(PriorityType item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
コード例 #12
0
 public void Update(TodoAndUsers item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
コード例 #13
0
 /// <summary>
 /// Implementação do método que altera um registro.
 /// </summary>
 /// <param name="obj">Classe que esta sendo alterado o registro.</param>
 public void Update(TEntity obj)
 {
     _db.Entry(obj).State = EntityState.Modified;
     _db.SaveChanges();
 }
コード例 #14
0
 public void Update(Projects item)
 {
     _context.Entry(item).State = EntityState.Modified;
 }
コード例 #15
0
 public void Update(TeamInfo item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
コード例 #16
0
ファイル: RolesRepository.cs プロジェクト: Errayse/task-list
 public void Update(RolesType item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
コード例 #17
0
        public void Update(Task task)
        {
            context.Entry(task).State = EntityState.Modified;

            context.SaveChanges();
        }
コード例 #18
0
 public void Update(AttachmentType item)
 {
     db.Entry(item).State = EntityState.Modified;
 }
コード例 #19
0
 public virtual void Update(TEntity entity)
 {
     Db.Entry(entity).State = EntityState.Modified;
     Db.SaveChanges();
 }
コード例 #20
0
 public void Update(User item)
 {
     db.Entry(item).State = EntityState.Modified;
 }