Ejemplo n.º 1
0
        public int Create(ToDoCreate request)
        {
            using (var con = GetConnection())
            {
                var cmd = con.CreateCommand();
                cmd.CommandText = "ToDo_Create";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@task", request.Task);
                cmd.Parameters.Add("@Id", SqlDbType.Int).Direction = ParameterDirection.Output;

                cmd.ExecuteNonQuery();

                return((int)cmd.Parameters["@Id"].Value);
            }
        }
Ejemplo n.º 2
0
        public bool CreateToDo(ToDoCreate model)
        {
            var entity =
                new ToDo()
            {
                OwnerID    = _userID,
                Title      = model.Title,
                Details    = model.Details,
                GroupID    = model.GroupID,
                IsDone     = false,
                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.ToDos.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(ToDoCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateToDoService();

            if (service.CreateToDo(model))
            {
                TempData["SaveResult"] = "Your note was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Note could not be created.");
            ViewBag.GroupID = new SelectList(db.Groups, "GroupID", "GroupName");
            return(View(model));
        }
Ejemplo n.º 4
0
 public int Create(ToDoCreate model)
 {
     return(toDoService.Create(model));
 }