Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,JavascriptCode")] Tasks tasks)
        {
            if (id != tasks.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tasks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TasksExists(tasks.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tasks));
        }
Ejemplo n.º 2
0
        public async ThreadingTasks.Task <IActionResult> Edit(int id, [Bind("TaskID,TaskTitle,TaskList")] Task task)
        {
            if (id != task.TaskID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(task);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.TaskID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(task));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Priority,Deadline,IsCompleted,ProjectId")] Models.Task task)
        {
            if (id != task.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(task);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Title", task.ProjectId);
            return(View(task));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description")] Project project)
        {
            if (id != project.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,ProjectID,Process,TaskName,Start,End,Status,Progress,Memo")] Thing thing)
        {
            if (id != thing.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(thing);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ThingExists(thing.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "ProjectName", thing.ProjectID);
            return(View(thing));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,InputParams,Finished,Resoult")] TaskInstance taskInstance)
        {
            if (id != taskInstance.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskInstance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskInstanceExists(taskInstance.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskInstance));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Category,ProjectName,StartDate,CompletionDate,Status,Priority,Comment")] Project project)
        {
            if (id != project.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> CheckTask(int id)
        {
            var task = await _tasksContext.Tasks.FindAsync(id);

            task.Done = task.Done == 0 ? 1 : 0;
            _tasksContext.Update(task);
            await _tasksContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Edit2(int?id, bool isDone)
        {
            var tableTasks = await _context.TableTasks.SingleOrDefaultAsync(m => m.Id == id);

            if (tableTasks == null)
            {
                return(NotFound());
            }
            tableTasks.IsDone = (bool)isDone;
            //return View(tableTasks);

            if (id != tableTasks.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tableTasks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TableTasksExists(tableTasks.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tableTasks));
        }
Ejemplo n.º 10
0
        public void Update_Updates_Todo()
        {
            var rand = new Random().Next();

            using (var context = new TasksContext(_options))
            {
                context.Todos.Add(new Todo()
                {
                    ID = rand, Description = "First", Completed = false
                });
                context.SaveChanges();
            }

            using (var context = new TasksContext(_options))
            {
                context.Update(new Todo()
                {
                    ID = rand, Description = "First", Completed = true
                });

                Assert.AreEqual(context.Todos.FirstOrDefault(f => f.ID == rand).Completed, true);
            }
        }
Ejemplo n.º 11
0
        public async void Save(ThoughtDto thoughtDto)
        {
            using (context)
            {
                Thought thought;
                if (thoughtDto.ThoughtId > 0)
                {
                    thought = context.Thoughts
                              .SingleOrDefaultAsync(t => t.ThoughtId == thoughtDto.ThoughtId)
                              .Result;

                    thought.Update(
                        thoughtDto.Description,
                        (int)thoughtDto.Timeframe.TimeframeType,
                        thoughtDto.Timeframe.TimeframeDateTime,
                        thoughtDto.Project);

                    try
                    {
                        context.Update <Thought>(thought);
                        await context.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
                else
                {
                    thought = Thought.Create(thoughtDto.Description, thoughtDto.SortId, (int)thoughtDto.Timeframe.TimeframeType, thoughtDto.Timeframe.TimeframeDateTime, thoughtDto.Project);
                    context.Thoughts.Add(thought);
                    context.SaveChanges();
                }
            }
        }