Example #1
0
        public int Create(string name, string description)
        {
            var list = new ShoppingList {
                Name = name, Description = description
            };

            _shoppingListRepository.Create(list);
            _shoppingListRepository.SaveChanges();

            return(list.Id);
        }
        public ShoppingList Create()
        {
            var shoppingList = new ShoppingList()
            {
                Title = GetNewListTitle()
            };

            _shoppingListRepository.Create(shoppingList);
            _unitOfWork.SaveChanges(); // Populates shoppingList.Id
            _permissionService.Create(_userContext.UserId, Permissions.View, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.Edit, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.Share, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.AddListItems, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.PickOrUnpickListItems, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.Edit, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.RemoveListItems, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.Delete, shoppingList.Id);
            _permissionService.Create(_userContext.UserId, Permissions.EditListItems, shoppingList.Id);
            _unitOfWork.SaveChanges();
            return(shoppingList);
        }
Example #3
0
 public async Task Create(ShoppingList shoppingList)
 {
     await _shoppingListRepository.Create(shoppingList);
 }
 // POST api/<controller>
 public void Post([FromBody] ShoppingList value)
 {
     _shoppingListRepository.Create(value, User.Identity.GetUserId());
 }
 public Item CreateItem(Item item)
 {
     return(_shoppingListRepository.Create(item));
 }