Example #1
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind(
                                                    "Id,Owner,Title,Description,Category,Type,Location,Lat,Lon,Radius,NegotiationMarker,Status,CreationDate,StartDate,EndDate,Renumeration,PaymentTerms,Currency,CoverPhoto,DatePretext")]
                                               iTask iTask)
        {
            if (id != iTask.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(iTask);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!iTaskExists(iTask.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(iTask));
        }
Example #2
0
        public void TestSave()
        {
            try
            {
                // task1 = new Task("testCre", "task1", new DateTime(2019, 12, 12));
                int id = InterfaceLayer.CreateNewTask("testCre", "task1", new DateTime(2019, 12, 12));


                Saved_Task = Task.GetTaskByID(id);
                Assert.AreEqual(Saved_Task.getDescription(), "task1");

                List <int> list = TaskDAL.GetTaskByColumn(1);
                if (!list.Contains(Saved_Task.getID()))
                {
                    Assert.Fail("didn't save the task to the correct column");
                }
            }
            catch (MileStone4.AlmogException ex)
            {
                Assert.Fail((String)ex.Value, new object[] { ex });
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message, new object[] { e });
            }
        }
Example #3
0
 /// <summary>
 /// Adds a Task to the collection.
 /// </summary>
 /// <param name="pTask">The task to add.</param>
 public void Add(iTask pTask)
 {
     lock (_tasks)
     {
         iTaskEntry entry = new TaskEntry(pTask, _factory.Create());
         _tasks.Add(entry.ID, entry);
     }
 }
        public async Task <ActionResult> Post([FromBody] iTask task)
        {
            if (task == null)
            {
                new BadRequestResult();
            }

            iTask added = await repo.CreateAsync(task);

            return(CreatedAtRoute("Get", new { id = added.Id }, task));
        }
Example #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TaskEntry(iTask pTask, iEventRecorder pEventRecorder)
        {
            if (pTask == null || pEventRecorder == null)
            {
                throw new NullReferenceException();
            }

            ID = Guid.NewGuid();
            Task = pTask;
            Recorder = pEventRecorder;
        }
Example #6
0
        public async Task <IActionResult> Create(
            [Bind(
                 "Id,Owner,Title,Description,Category,Type,Location,Lat,Lon,Radius,NegotiationMarker,Status,CreationDate,StartDate,EndDate,Renumeration,PaymentTerms,Currency,CoverPhoto,DatePretext")]
            iTask iTask)
        {
            if (ModelState.IsValid)
            {
                _context.Add(iTask);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(iTask));
        }
        public async Task <ActionResult> Put(string number, [FromBody] iTask task)
        {
            if (number == null || task.number.ToString() != number)
            {
                return(new BadRequestResult());
            }
            var t = await repo.RetrieveAsync(number);

            if (t == null)
            {
                return(NotFound());
            }
            await repo.UpdateAsync(number, task);

            return(new NoContentResult());
        }
Example #8
0
        public void TestUpdate()
        {
            try
            {
                Saved_Task.GetUpdate("updatedTask1", "updateedDes", null).Invoke(1);

                iTask task2 = Task.GetTaskByID(Saved_Task.getID());
                Assert.AreEqual(task2.getTitle(), "updatedTask1");
            }
            catch (MileStone4.AlmogException ex)
            {
                Assert.Fail((String)ex.Value, new object[] { ex });
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message, new object[] { e });
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World! Getting ready...");

            List <Type> Types = Assembly.GetExecutingAssembly().GetTypes().
                                Where(x => x.GetInterface("iTask") != null).
                                ToList();

            foreach (var type in Types)
            {
                Tasks.Add((iTask)Activator.CreateInstance(type));
            }

            Tasks = Tasks.OrderBy(x => x.ID).ToList();

            Console.WriteLine("Available tasks:");
            foreach (iTask task in Tasks)
            {
                Console.WriteLine($" > [{task.ID}] - {task.Name}");
            }

            Console.WriteLine("Enter task index to invoke: ");
            while (true)
            {
                try
                {
                    Console.Write(" > ");
                    String Command = Console.ReadLine();

                    if (Command == "exit")
                    {
                        break;
                    }
                    else if (Command == "clear")
                    {
                        Console.Clear(); continue;
                    }

                    Int32 Index = Int32.Parse(Command);

                    iTask Task = Tasks.First(x => x.ID == Index);

                    Task.Invoke();
                }
                catch (ArgumentNullException) { }
                catch (FormatException)
                {
                    Console.WriteLine("Invalid format");
                }
                catch (ArgumentOutOfRangeException) {
                    Console.WriteLine("Unknown task index");
                }
                catch (Exception Ex) {
                    Ex = (Ex.InnerException != null) ? Ex.InnerException : Ex;
                    Console.WriteLine($"Oops... {Ex.GetType().Name} : {Ex.Message}");
                }
            }

            Console.WriteLine("Done. Waiting key press for exit...");
            Console.ReadKey();
        }
Example #10
0
        public static void UpdateNewTask(String Title, String Description, DateTime?DueDate, int column_id, int ID)
        {
            iTask task = Task.GetTaskByID(ID);

            task.GetUpdate(Title, Description, DueDate).Invoke(column_id);
        }