Exemplo n.º 1
0
        public ActionResult Delete(long id, FormCollection collection)
        {
            bool success = false;

            try
            {
                long accountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id;
                ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext);
                ToDoItem           item       = repository.Find(id);
                if (item != null)
                {
                    if (item.AccountId == accountId)
                    {
                        success = repository.Delete(id);
                    }
                }
            }
            catch
            {
            }

            return(new JsonResult()
            {
                Data = MerchantTribe.Web.Json.ObjectToJson(new { result = success })
            });
        }
        public void When_round_tripping_a_todo_item()
        {
            var item = new ToDoItem
            {
                ItemId      = Guid.NewGuid().ToString(),
                ItemText    = "Test round-trip integration",
                CreatedAt   = DateTimeOffset.UtcNow.AddDays(-1),
                CompletedAt = null
            };

            classUnderTest.Save(item);
            var result = classUnderTest.Find(item.ItemId);

            Assert.That(result.ItemText, Is.EqualTo(item.ItemText));
            Assert.That(result.CreatedAt, Is.EqualTo(item.CreatedAt));
            Assert.That(result.CompletedAt, Is.Null);
        }
Exemplo n.º 3
0
        public ActionResult Toggle(long id)
        {
            bool success = false;

            try
            {
                long accountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id;
                ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext);
                ToDoItem           item       = repository.Find(id);
                if (item != null)
                {
                    if (item.AccountId == accountId)
                    {
                        item.IsComplete = !item.IsComplete;
                        success         = repository.Update(item);
                    }
                }
            }
            catch
            {
            }

            return(new RedirectResult("~/todo"));
        }
Exemplo n.º 4
0
        public ActionResult Delete(long id, FormCollection collection)
        {
            bool success = false;

            try
            {

                long accountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id;
                ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext);
                ToDoItem item = repository.Find(id);
                if (item != null)
                {
                    if (item.AccountId == accountId)
                    {
                        success = repository.Delete(id);
                    }
                }
            }
            catch
            {
                
            }

            return new JsonResult() { Data = MerchantTribe.Web.Json.ObjectToJson(new { result = success }) };
        }
Exemplo n.º 5
0
        public ActionResult Toggle(long id)
        {
            bool success = false;

            try
            {

                long accountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id;
                ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext);
                ToDoItem item = repository.Find(id);
                if (item != null)
                {
                    if (item.AccountId == accountId)
                    {
                        item.IsComplete = !item.IsComplete;
                        success = repository.Update(item);
                    }
                }
            }
            catch
            {

            }

            return new RedirectResult("~/todo");            
        }