Exemple #1
0
        public BoxesModel GetBoxForCurrentUser()
        {
            var currentUser = _userRepository.GetFirstOrDefault(u => u.UserName == User.Identity.Name);

            var dbBox = _boxRepository.GetFirstOrDefault(b => b.PawzeUser.UserName == currentUser.UserName);

            if (dbBox == null)
            {
                return(new BoxesModel
                {
                    BoxItems = new BoxItemsModel[]
                    {
                        new BoxItemsModel(), new BoxItemsModel(), new BoxItemsModel(), new BoxItemsModel()
                    }
                });
            }
            else
            {
                return(Mapper.Map <BoxesModel>(dbBox));
            }
        }