Exemple #1
0
        public UserMessageFolder CreateDefaultFolder(string userName)
        {
            using (var context = new PhobosCoreContext())
            {
                var folder = new UserMessageFolder()
                {
                    User = context.Users.Include(x => x.Roles).First(x => x.Username == userName),
                    Name = InboxFolderName,
                    IsInboxFolder = true
                };

                context.UserMessageFolders.Add(folder);

                context.SaveChanges();

                return folder;
            }
        }
Exemple #2
0
        public UserMessageFolder GetDraftFolder(string userName)
        {
            using (var context = new PhobosCoreContext())
            {
                var folder = context.UserMessageFolders
                    .Include(x => x.User)
                    .Include(x => x.User.Roles)
                    .Where(x => x.User.Username == userName && x.Name == DraftFolderName)
                    .FirstOrDefault();

                if (folder == default(UserMessageFolder))
                {
                    folder = new UserMessageFolder()
                    {
                        User = context.Users.First(x => x.Username == userName),
                        Name = DraftFolderName,
                        IsDraftFolder = true
                    };

                    context.UserMessageFolders.Add(folder);
                    context.SaveChanges();
                }

                return folder;
            }
        }
Exemple #3
0
        public UserMessageFolder SaveFolder(UserMessageFolder model)
        {
            using (var context = new PhobosCoreContext())
            {
                model.User = context.Users.Include(x => x.Roles).First(x => x.Username == model.User.Username);

                if (model.Id == 0 || !context.UserMessageFolders.Any(x => x.Id == model.Id))
                {
                    context.UserMessageFolders.Add(model);
                }
                else
                {
                    context.UserMessageFolders.First(x => x.Id == model.Id).Icon = model.Icon;
                    context.UserMessageFolders.First(x => x.Id == model.Id).IconColor = model.IconColor;
                    context.UserMessageFolders.First(x => x.Id == model.Id).Name = model.Name;
                }

                context.SaveChanges();

                return model;
            }
        }
        public ActionResult CreateFolder()
        {
            var mapper = AutoMapperConfiguration.GetMapper();
            var foldersForUser = messageService.GetAllFoldersForUser(SessionManager.CurrentUsername);

            var folder = new UserMessageFolder()
            {
                User = new UserAccount()
                {
                    Username = SessionManager.CurrentUsername
                },
            };

            var viewModel = mapper.Map<UserMessageFolder, MessageMailBoxFolderViewModel>(folder);
            viewModel.Folders = mapper.Map<List<UserMessageFolder>, List<MessageMailBoxFolderViewModel>>(foldersForUser);

            return this.View("EditFolder", viewModel);
        }
 public UserMessageFolder SaveFolder(string userName, UserMessageFolder model)
 {
     return this.Repository.SaveFolder(model);
 }
 public UserMessageFolder SaveFolder(UserMessageFolder model)
 {
     throw new NotImplementedException();
 }