Beispiel #1
0
 public void AddListToDatabase(ToDoList.DomainModels.ToDoList list)
 {
     //this happens when editing an existing list
     if (_database.ToDoLists.SingleOrDefault(t => t.ListId == list.ListId) != null)
     {
         var tempList = _database.ToDoLists.SingleOrDefault(t => t.ListId == list.ListId);
         tempList.ListName = list.ListName;
     }
     //this happens when adding brand new list
     else
     {
         _database.ToDoLists.Add(list);
     }
     _database.SaveChanges();
 }
Beispiel #2
0
        public HttpResponseMessage CreateList(CreateListRequest request)
        {
            var response   = new CreateListResponse();
            var tempList   = new ToDoList.DomainModels.ToDoList();
            int tempUserId = _sessionManager.GetSession(request.SessionId).User.ToDoUserId;

            tempList.ListName = request.ListName;
            tempList.UserId   = tempUserId;

            if (_sessionManager.IsActive(request.SessionId))
            {
                _listManager.AddListToDatabase(tempList);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, response));
            }
        }
Beispiel #3
0
        public ActionResult SaveList(ListFormViewModel model)
        {
            if (_sessionManager.IsActive(model.SessionId))
            {
                var tempList = new ToDoList.DomainModels.ToDoList();
                tempList.ListId   = model.ToDoList.ListId;
                tempList.ListName = model.ToDoList.ListName;
                tempList.UserId   = model.ToDoList.UserId;

                _listManager.AddListToDatabase(tempList);

                return(RedirectToAction("ListIndex", model));
            }
            else
            {
                var viewModel = new ToDoUser();
                return(RedirectToAction("SignInForm", "Auth", viewModel));
            }
        }