Пример #1
0
        // GET: todos
        public ActionResult Index()
        {
            var todolist    = ItodoInterface.getTodos().ToList();
            var todosDetail = new todo();

            return(View(todolist));
        }
Пример #2
0
 public void updateTodo(todo todo)
 {
     todolistEntities.Entry(todo).State = System.Data.Entity.EntityState.Modified;
     todolistEntities.SaveChanges();
     // var todoUpdate = new todo(); //back here
     // throw new NotImplementedException();
 }
        public ActionResult Create(Examen3_Progra4.Models.todoEstructure model,string statusList)
        {
            string valStatus = (statusList.Equals("Outgoing") ? "O" : statusList.Equals("Cancel") ? "C" : "D");

                todo myTodo = new todo
                {
                    nombre=model.nameTodo,
                    descripcion=model.descriptionTodo,
                    fechaI=model.dateI,
                    fechaF=model.dateF,
                    status=valStatus,
                    userOwner=this.User.Identity.Name,
                };
                try
                {
                    db.todos.AddObject(myTodo);
                    db.SaveChanges();
                }
                catch
                {
                    ModelState.AddModelError("", "It can't create the new TO-DO");
                    return View(model);
                }

                return RedirectToAction("MyToDo", "Todo");

            // If we got this far, something failed, redisplay form
        }
Пример #4
0
        static void Main(string[] args)
        {
            string input4;

            do
            {
                string input1, input2, input3;

                Console.WriteLine("This your To-do List");
                Console.WriteLine("Enter in the description of your to-do....EX. Do your coding projects!!!: ");
                input1 = Console.ReadLine();
                Console.WriteLine("Enter the due date... EX. 01/13/89: ");
                input2 = Console.ReadLine();
                Console.WriteLine("Enter the priority...EX. high, normal or low: ");
                input3 = Console.ReadLine();

                todo newitem = new todo(input1, input2, input3);
                Console.WriteLine("Desciption: {0} DueDate: {1} Priority: {2}", newitem.description, newitem.duedate, newitem.priority);

                List <todo> toadd = new List <todo>();
                toadd.Add(newitem);
                Console.WriteLine(toadd);

                Console.WriteLine("Do you want to add another item  to the list? (yes or no)");
                input4 = Console.ReadLine();
            } while (input4 == "yes");
        }
Пример #5
0
        public IHttpActionResult Puttodo(int id, todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != todo.id)
            {
                return(BadRequest());
            }

            db.Entry(todo).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!todoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #6
0
        public void deleteTodo(int todoId)
        {
            todo DeleteTodoItem = todolistEntities.todos.Find(todoId);

            todolistEntities.todos.Remove(DeleteTodoItem);
            todolistEntities.SaveChanges();
            // throw new NotImplementedException();
        }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            todo todo = db.todoes.Find(id);

            db.todoes.Remove(todo);
            db.SaveChanges();
            return(RedirectToAction("Index", "Profile"));
        }
Пример #8
0
        public ActionResult <IEnumerable <NeedToDo> > Get(todo td)
        {
            IEnumerable <NeedToDo> todo = from i in db.NeedToDo
                                          where (i.StudentId == td.StudentId) && (i.Hide == td.hide)
                                          select i;

            return(todo.ToList());
        }
Пример #9
0
 public ActionResult Edit([Bind(Include = "todo_id,todo_date,content,archive,user_id")] todo todo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(todo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.user_id = new SelectList(db.users, "user_id", "user_asp_id", todo.user_id);
     return(View(todo));
 }
Пример #10
0
        public IHttpActionResult Gettodo(int id)
        {
            todo todo = db.Todos.Find(id);

            if (todo == null)
            {
                return(NotFound());
            }

            return(Ok(todo));
        }
Пример #11
0
        // GET api/todo/5
        public HttpResponseMessage Get(int id)
        {
            todo todo = db.todo.SingleOrDefault(t => t.id == id);

            if (todo == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse <todo>(HttpStatusCode.OK, todo));
        }
Пример #12
0
        // GET: todos/Edit/5
        public ActionResult Edit(int id)
        {
            var getDetail   = ItodoInterface.getTodoById(id);
            var todosDetail = new todo();

            todosDetail.id           = id;
            todosDetail.todo_title   = getDetail.todo_title;
            todosDetail.todo_content = getDetail.todo_content;

            return(View(todosDetail));
        }
Пример #13
0
        // POST api/todo
        public HttpResponseMessage Post([FromBody] todo todo)
        {
            if (ModelState.IsValid)
            {
                db.todo.Add(todo);
                db.SaveChanges();

                return(Request.CreateResponse <todo>(HttpStatusCode.OK, todo));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
        }
Пример #14
0
 public int addNewEntrt(todo data)
 {
     try
     {
         virtualDB.toDoTable.Add(data);
         return(1);
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Пример #15
0
        public IHttpActionResult Posttodo(todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Todos.Add(todo);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = todo.id }, todo));
        }
Пример #16
0
 public int kayitYeni(todo data)
 {
     try
     {
         Sanaldatabase.todoTablo.Add(data);
         return(1);
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Пример #17
0
 public ActionResult Edit(todo todo, int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         ItodoInterface.updateTodo(todo);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #18
0
        public IHttpActionResult Deletetodo(int id)
        {
            todo todo = db.Todos.Find(id);

            if (todo == null)
            {
                return(NotFound());
            }

            db.Todos.Remove(todo);
            db.SaveChanges();

            return(Ok(todo));
        }
Пример #19
0
        public ActionResult Create([Bind(Include = "todo_id,todo_date,content,archive,user_id")] todo todo)
        {
            todo.todo_date = DateTime.Now;
            todo.archive   = "false";
            if (ModelState.IsValid)
            {
                db.todoes.Add(todo);
                db.SaveChanges();
                return(RedirectToAction("Index", "Profile"));
            }

            ViewBag.user_id = new SelectList(db.users, "user_id", "user_asp_id", todo.user_id);
            return(View(todo));
        }
Пример #20
0
 // GET: Todo/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         // TODO: Add delete logic here
         todo t = db.todos.Single(x => x.id == id);
         db.todos.DeleteOnSubmit(t);
         db.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #21
0
 // GET: Todo/Edit/5
 public ActionResult Edit(int id)
 {
     try
     {
         // TODO: Add update logic here
         todo t = db.todos.Single(x => x.id == id);
         t.status = 1;
         db.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #22
0
 public ActionResult Create(todo collection)
 {
     try
     {
         // TODO: Add insert logic here
         collection.status = 0;
         db.todos.InsertOnSubmit(collection);
         db.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #23
0
 public string PostTodo(ToDoDTO todo)
 {
     using (APIEntities api = new APIEntities())
     {
         var newTodo = new todo
         {
             todo_id   = todo.ID,
             value     = todo.Value,
             completed = (todo.Completed) ? 1 : 0
         };
         api.todoes.Add(newTodo);
         api.SaveChanges();
         return("success");
     }
 }
Пример #24
0
        public void AddTodo()
        {
            todo param = new todo();

            param.id           = 0;
            param.Expiration   = _v.Exp.Value;
            param.alarmhours   = Int32.Parse(_v.Hh.Text);
            param.alarmMinutes = Int32.Parse(_v.Mm.Text);
            param.ph_id        = pid;
            param.todo1        = _v.RichTextBox2.Text;
            _r.AddTo(param);
            factory.IntervalInMinutes(param.alarmhours, param.alarmMinutes, 1, () =>
            {
                MessageBox.Show(param.todo1);
                SystemSounds.Beep.Play();
            });
        }
Пример #25
0
		private void LoadTodosLater()
		{
			con.OpenCon();
			string cmd = "SELECT * FROM todo WHERE class_id=@class_id AND done=0";
			MySqlCommand command = new MySqlCommand(cmd, con.getCon());

			command.Parameters.AddWithValue("@class_id", user.ClasaId);
			command.Parameters.AddWithValue("@date1", DateTime.Now.ToString("dd MMMM yyyy"));

			using (MySqlDataReader reader = command.ExecuteReader())
			{
				todo todo = new todo();

				
				while (reader.Read())
				{

					//DateTime myDate = Convert.ToDateTime(reader["duedate"].ToString());
					DateTime myDate = DateTime.ParseExact(reader["duedate"].ToString(),"dd MMMM yyyy",CultureInfo.InvariantCulture);

					DateTime now = DateTime.Now;
					if (myDate.Subtract(now).TotalHours < 0)
					{

						todo.id = reader["id"].ToString();
						todo.title = reader["title"].ToString();
						todo.description = reader["description"].ToString();
						todo.link = reader["link"].ToString();
						todo.file = reader["file"].ToString();
						todo.user_id = reader["class_id"].ToString();
						todo.done = reader["done"].ToString();
						todo.mat = reader["mat"].ToString();
						todo.duedate = reader["duedate"].ToString();

						todosM.Add(todo);
					}


				}

			}

			con.CloseCon();

		}
Пример #26
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                using (DbModels db = new DbModels())
                {
                    todo todo = db.todoes.FirstOrDefault(x => x.Id == id);
                    db.todoes.Remove(todo);
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #27
0
        // GET: ToDo/Details/5
        public ActionResult Details(int?id)
        {
            ViewBag.Updates      = db.updates.ToList().OrderBy(t => t.update_date).Reverse();
            ViewBag.contentNote  = db.contents.ToList().OrderBy(p => p.content_id).Reverse();
            ViewBag.responseNote = db.responses.ToList().OrderBy(s => s.response_date).Reverse();
            ViewBag.reactionNote = db.reactions.ToList();
            ViewBag.users        = db.users.ToList();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            todo todo = db.todoes.Find(id);

            if (todo == null)
            {
                return(HttpNotFound());
            }
            return(View(todo));
        }
Пример #28
0
        public ActionResult Edit(int id, todo todo)
        {
            try
            {
                // TODO: Add update logic here

                using (DbModels db = new DbModels())
                {
                    db.Entry(todo).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #29
0
        public ActionResult Create(todo todoInsert)
        {
            try
            {
                // TODO: Add insert logic here
                var Newtodos = new todo();
                Newtodos.todo_title   = todoInsert.todo_title;
                Newtodos.todo_content = todoInsert.todo_content;
                Newtodos.date         = todoInsert.date;
                AlertTimeClass clock = new AlertTimeClass(Newtodos.date);

                ItodoInterface.insertTodo(Newtodos);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #30
0
        // DELETE api/todo/5
        public HttpResponseMessage Delete(int id)
        {
            if (ModelState.IsValid)
            {
                todo exTodo = db.todo.SingleOrDefault(t => t.id == id);

                if (exTodo == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                db.Entry(exTodo).State = EntityState.Deleted;
                db.SaveChanges();

                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            //return BadRequest(ModelState);
        }
Пример #31
0
        public ActionResult Create(todo todo)
        {
            try
            {
                // TODO: Add insert logic here

                using (DbModels db = new DbModels())
                {
                    if (ModelState.IsValid == true)
                    {
                        db.todoes.Add(todo);
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }