protected override async Task ActionAsync()
        {
            var _siteId = Input.Data.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, _siteId);

            // var notificationDb =  await GetAsync<NotificationBusinessModel>(_siteId, _siteId, NotificationBusinessModule.ModuleName, "Notification");

            var notificationItemDb = await SaveFreeCommand.SaveItemDataModelAsync <NotificationItemBusinessModel>(_dataFactory, Input.Data.Data, Input.UserId, NotificationItemBusinessModule.ModuleName);

            var elements =
                await SaveFreeCommand.GetElementsAsync(_dataFactory, notificationItemDb, Input.Data.Data.Elements);

            // On enregistre l'element
            var freeBusinessModel = (NotificationItemBusinessModel)notificationItemDb.Data;

            freeBusinessModel.Elements = elements;

            await _dataFactory.SaveChangeAsync();

            var siteInfo = await SiteMap.SiteUrlAsync(_routeManager, _dataFactory, _siteId);

            var userDb = await _userService.FindApplicationUserByIdAsync(Input.UserId);

            foreach (var siteUserId in Input.Data.SiteUserIds)
            {
                var siteUserDb = await _siteUserService.FindAsync(siteUserId);
                await SendEmailAsync(siteInfo, _emailService, siteUserDb, userDb, elements, _siteId);
            }
        }
示例#2
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.Site.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var itemDataModel = await SaveFreeCommand.SaveItemDataModelAsync <NewsBusinessModel>(_dataFactory, Input.Data, Input.UserId, "News");

            var freeBusinessModel = (NewsBusinessModel)itemDataModel.Data;

            freeBusinessModel.DisplayMode       = Input.Data.DisplayMode;
            freeBusinessModel.NumberItemPerPage = Input.Data.NumberItemPerPage;

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(siteId);

            Result.Data        = new ExpandoObject();
            Result.Data.Master = await _moduleManager.GetMasterAsync(Input.Data.Site);

            var roots = _newsBusinessModule.GetRootMetadata(new GetRootMetaDataInput
            {
                ItemDataModel = itemDataModel,
                DataFactory   = _dataFactory
            });

            Result.Data.Url = RouteManager.GetPath(NewsBusinessModule.Url, roots);
        }
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.Site.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var itemDataModel = await SaveFreeCommand.Get <SocialBusinessModel>(Input.Data, _dataFactory, "Social");

            itemDataModel.Data = Input.Data.Data;

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(siteId);

            Result.Data        = new ExpandoObject();
            Result.Data.Master = await _moduleManager.GetMasterAsync(Input.Data.Site);

            Result.Data.ModuleId = itemDataModel.Id;

            var roots = _socialBusinessModule.GetRootMetadataTemp(new GetRootMetaDataInput
            {
                ItemDataModel = itemDataModel,
                DataFactory   = _dataFactory
            });

            Result.Data.Url = RouteManager.GetPath(SocialBusinessModule.Url, roots);
        }
        protected override async Task ActionAsync()
        {
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data.Site.SiteId);


            var itemDataModel = await GetMasterItemDataModelAsync(_dataFactory, Input.Data.Site.SiteId, true);

            if (itemDataModel == null)
            {
                itemDataModel              = new ItemDataModel();
                itemDataModel.SiteId       = Input.Data.Site.SiteId;
                itemDataModel.ParentId     = Input.Data.Site.SiteId;
                itemDataModel.PropertyName = "Master";
                itemDataModel.Module       = "Master";
                itemDataModel.Index        = 100; // TODO
                _dataFactory.Add(itemDataModel);
            }

            var elements =
                await SaveFreeCommand.GetElementsAsync(_dataFactory, itemDataModel, Input.Data.Elements);

            // On enregistre l'element
            var freeBusinessModel = new MasterBusinessModel();

            freeBusinessModel.Elements = elements;
            itemDataModel.Data         = freeBusinessModel;

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(Input.Data.Site.SiteId);

            Result.Data = await _moduleManager.GetMasterAsync(Input.Data.Site);
        }
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.Site.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var itemDataModel = await SaveFreeCommand.SaveItemDataModelAsync <NotificationItemBusinessModel>(_dataFactory, Input.Data, Input.UserId, NotificationItemBusinessModule.ModuleName);

            var isNew = string.IsNullOrEmpty(itemDataModel.Id);

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(siteId);

            GetNewsItemResult newsItemResult = null;

            if (isNew)
            {
                newsItemResult =
                    await
                    GetNewsItemCommand.GetNewsItemResult(_dataFactory, _userService, itemDataModel, Input.UserId);
            }
            Result.Data = new
            {
                NewsItem = newsItemResult
            };
        }
示例#6
0
        protected override async Task ActionAsync()
        {
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data);

            //  int sizeBytes = await Data.ItemRepository.CountSiteSizeBytesAsync(Input);

            // var numberUnreadMessage = await _messageService.CountUnreadChatAsync(new BoxId() {Id = Input.Data, Type = TypeBox.Site},
            //     new BoxId() {Id = Input.UserId, Type = TypeBox.User});


            var administrationModel = new AdministrationModel();

            //   administrationModel.NumberUnreadMessage = numberUnreadMessage;

            /*administrationModel.MaxTotalSizeBytes = 1048576*24;
             * administrationModel.TotalSizeBytes = sizeBytes;*/

            // var seo = await GetSeoCommand.GetSeoItemDataModelAsync(Data, Input.Data);
            //administrationModel.IdSeoWarning = seo.

            Result.Data = administrationModel;

            /*long giga = sizeBytes/8589934592;
             * int mega = sizeBytes/1048576;
             * int kilo = (sizeBytes - mega*1048576)/1024;*/
        }
示例#7
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            if (Input.UserId == Input.Data.UserId)
            {
                throw new ArgumentException("User cannot remove is own role");
            }

            var modifiedUserDb = await _userService.FindApplicationUserByIdAsync(Input.Data.UserId);

            if (modifiedUserDb != null)
            {
                var claim = modifiedUserDb.Roles.FirstOrDefault(c => c == siteId);
                if (claim != null)
                {
                    modifiedUserDb.Roles.Remove(claim);
                    await _userService.SaveAsync(modifiedUserDb);
                }
                else
                {
                    throw new ArgumentException("User do not have this role");
                }
            }
            else
            {
                throw new ArgumentException("User does no exist");
            }
        }
示例#8
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.Site.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var itemDataModel =
                await _dataFactory.ItemRepository.GetItemAsync(siteId, Input.Data.ModuleId, false, true);

            var addSiteBusinessModel = (AddSiteBusinessModel)itemDataModel.Data;

            addSiteBusinessModel.Templates = Input.Data.Templates;
            addSiteBusinessModel.UrlConditionsGeneralesUtilisations = Input.Data.UrlConditionsGeneralesUtilisations;

            var elements =
                await SaveFreeCommand.GetElementsAsync(_dataFactory, itemDataModel, Input.Data.Elements);

            // On enregistre l'element
            addSiteBusinessModel.Elements = elements;

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(siteId);

            Result.Data        = new ExpandoObject();
            Result.Data.Master = await _moduleManager.GetMasterAsync(Input.Data.Site);
        }
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var seoItemDataModel = await GetSeoCommand.GetSeoItemDataModelAsync(_dataFactory, siteId, true);

            if (seoItemDataModel == null)
            {
                // Insert
                var masterItemDataModel = await SaveMasterCommand.GetMasterItemDataModelAsync(_dataFactory, siteId);

                seoItemDataModel              = new ItemDataModel();
                seoItemDataModel.SiteId       = siteId;
                seoItemDataModel.ParentId     = masterItemDataModel.Id;
                seoItemDataModel.PropertyName = "Seo";
                seoItemDataModel.Module       = "Seo";
                seoItemDataModel.Index        = 100; // TODO

                _dataFactory.Add(seoItemDataModel);
            }

            seoItemDataModel.Data = Input.Data.Seo;

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(siteId);
        }
        protected override async Task ActionAsync()
        {
            var boxId = Input.Data.BoxId;

            if (boxId.Type == TypeBox.Site)
            {
                await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, boxId.Id);
            }
            else if (boxId.Type == TypeBox.User)
            {
                if (boxId.Id != Input.UserId)
                {
                    throw new NotAuthorizedException("You are not authorized to process this action.");
                }
            }

            await _messageService.SaveRead(Input.Data.ChatId, new Read()
            {
                CreateDate = DateTime.Now, Id = new BoxId()
                {
                    Id = Input.UserId, Type = TypeBox.User
                }
            });

            var chat = await _messageService.GetChatAsync(Input.Data.ChatId);

            var chatItem = await ListMessageCommand.MapChatItem(_logger, _siteMap, _userService, chat, Input.UserId);

            Result.Data = new GetMessageResult
            {
                Chat = chatItem
            };
        }
示例#11
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;

            if (Input.Data.IsVerifyAuthorisation)
            {
                await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);
            }

            Result.Data = await LoadSeoBusinessModelAsync(_dataFactory, siteId);
        }
        protected override async Task ActionAsync()
        {
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data.Site.SiteId);

            await _dataFactory.DeleteAsync <DataModelBase>(Input.Data.Site.SiteId, Input.Data.ModuleId);

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(Input.Data.Site.SiteId);

            Result.Data = await _moduleManager.GetMasterAsync(Input.Data.Site);
        }
示例#13
0
        protected override async Task ActionAsync()
        {
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data.Site.SiteId);

            var siteId = Input.Data.Site.SiteId;

            await UpdateMenuItemsAsync(siteId, Input.Data.MenuItems, "MenuItems");
            await UpdateMenuItemsAsync(siteId, Input.Data.PrivateMenuItems, "PrivateMenuItems");
            await UpdateMenuItemsAsync(siteId, Input.Data.BottomMenuItems, "BottomMenuItems");

            await _dataFactory.SaveChangeAsync();

            await _cacheProvider.UpdateCacheAsync(Input.Data.Site.SiteId);

            Result.Data = await _moduleManager.GetMasterAsync(Input.Data.Site);
        }
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var siteUserDb = await _siteUserService.FindAsync(Input.Data.SiteUserId);

            if (!string.IsNullOrEmpty(siteUserDb.UserId))
            {
                throw new ArgumentException("L'utilisateur est déjà inscrit");
            }

            var siteInfo = await SiteMap.SiteUrlAsync(_routeManager, _dataFactory, Input.Data.SiteId);

            var userDb = await _userService.FindApplicationUserByIdAsync(Input.UserId);

            await SendEmailAsync(siteInfo, _emailService, siteUserDb, userDb);
        }
示例#15
0
        protected override async Task ActionAsync()
        {
            var siteUserId = Input.Data.SiteUserId;
            var siteId     = Input.Data.SiteId;
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var siteUserDb = await _siteUserService.FindAsync(siteUserId);

            ApplicationUser userDb = null;

            var userId = siteUserDb.UserId;

            if (!string.IsNullOrEmpty(siteUserDb.UserId))
            {
                userDb = await _userService.FindApplicationUserByIdAsync(userId);
            }

            Result.Data = ListUserCommand.MapUserResult(userDb, siteId, siteUserDb);
        }
示例#16
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data;
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var usersDb = await _userService.UserByRoleAsync(siteId);

            var siteUsersDb = await _siteUserService.FindBySiteId(siteId);

            var users = new List <UserResult>();

            foreach (var siteUserDbModel in siteUsersDb)
            {
                var us   = usersDb.FirstOrDefault(u => u.Id == siteUserDbModel.UserId);
                var user = MapUserResult(us, siteId, siteUserDbModel);
                users.Add(user);
            }

            Result.Data = new ListUserResult()
            {
                Users = users
            };
        }
示例#17
0
        protected override async Task ActionAsync()
        {
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data);


            var itemDataModel = (await
                                 _dataFactory.ItemRepository.GetItemsAsync(Input.Data, new ItemFilters {
                ParentId = Input.Data, Module = MasterBusinessModule.ModuleName
            }))
                                .FirstOrDefault();

            if (itemDataModel == null)
            {
                Result.ValidationResult.AddError("NO_DATA_FOUND");
                return;
            }

            var moduleFree = (MasterBusinessModel)itemDataModel.Data;

            //TODO Remove
            var metaKeywords = moduleFree.Elements.FirstOrDefault(e => e.Property == "MetaKeyword");

            if (metaKeywords != null)
            {
                moduleFree.Elements.Remove(metaKeywords);
            }
            // TODO Remove
            var metaDescription = moduleFree.Elements.FirstOrDefault(e => e.Property == "MetaDescription");

            if (metaDescription != null)
            {
                moduleFree.Elements.Remove(metaDescription);
            }

            Result.Data = moduleFree;
        }
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;

            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var userDb = await _userService.FindApplicationUserByIdAsync(Input.UserId);

            var result = await SaveUserAsync(_siteUserService, _userService, userDb, Input.Data);

            if (result.SendMailAdmin != null)
            {
                await SendEmailAsync(_routeManager, _dataFactory, _emailService, result.SendMailAdmin);
            }

            Result.Data = new SaveSiteUserOutput()
            {
                SiteUserId = result.SiteUserId
            };
            if (!string.IsNullOrEmpty(result.Error))
            {
                Result.ValidationResult.AddError(result.Error);
            }
        }
示例#19
0
        protected override async Task ActionAsync()
        {
            var siteId = Input.Data.SiteId;
            await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, siteId);

            var tagsDbModel = await _tagsServiceMongo.FindTags(siteId, Input.Data.Type);

            if (tagsDbModel == null)
            {
                tagsDbModel = new TagsDbModel()
                {
                    SiteId   = siteId,
                    Type     = Input.Data.Type,
                    ModuleId = Input.Data.ModuleId,
                    Tags     = new List <TagDbModel>()
                };
            }

            foreach (var tag in Input.Data.Tags)
            {
                TagDbModel tagDbModel = null;
                if (!string.IsNullOrEmpty(tag.Id))
                {
                    tagDbModel = tagsDbModel.Tags.FirstOrDefault(t => t.Id == tag.Id);
                }
                if (tagDbModel == null)
                {
                    tagDbModel = new TagDbModel();
                    tagsDbModel.Tags.Add(tagDbModel);
                }

                tagDbModel.Name      = tag.Name;
                tagDbModel.IsDeleted = tag.IsDeleted;
            }
            await _tagsServiceMongo.SaveAsync(tagsDbModel);
        }
示例#20
0
        protected override async Task ActionAsync()
        {
            var boxId = Input.Data.BoxId;

            if (boxId.Type == TypeBox.Site)
            {
                await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, boxId.Id);
            }
            else if (boxId.Type == TypeBox.User)
            {
                if (boxId.Id != Input.UserId)
                {
                    throw new NotAuthorizedException("You are not authorized to process this action.");
                }
            }

            var limit = 20;

            var getChatsFilter = new GetChatsFilter
            {
                Limit = limit
            };

            var filterDate = Input.Data.Filter.Date;

            if (filterDate.HasValue)
            {
                if (Input.Data.Filter.IsPrevious)
                {
                    getChatsFilter.DateGt = filterDate.Value.ToLocalTime();
                }
                else
                {
                    getChatsFilter.DateLt = filterDate.Value.ToLocalTime();
                }
            }
            else
            {
                getChatsFilter.DateLt = DateTime.Now;
            }

            var chats = await _messageService.GetChatsAsync(boxId, getChatsFilter);

            var chatsResult = new List <ChatItem>();

            foreach (var chat in chats)
            {
                try
                {
                    var chatItem = await MapChatItem(_logger, _sitemap, _userService, chat, Input.UserId);

                    chatsResult.Add(chatItem);
                }
                catch (Exception exception)
                {
                    _logger.LogError(exception, "Exception deserialize message ChatItem json");
                }
            }

            var lastItem  = chatsResult.OrderBy(c => c.LastMessageDate).FirstOrDefault();
            var firstItem = chatsResult.OrderByDescending(c => c.LastMessageDate).FirstOrDefault();

            var  datePrevious = firstItem?.LastMessageDate;
            var  dateNext     = lastItem?.LastMessageDate;
            long nbNext       = 0;
            long nbPrevious   = 0;

            if (datePrevious.HasValue)
            {
                nbPrevious =
                    await _messageService.CountChatAsync(boxId, new CountChatFilters { DateGt = datePrevious.Value });
            }
            if (dateNext.HasValue)
            {
                nbNext = await _messageService.CountChatAsync(boxId, new CountChatFilters { DateLt = dateNext.Value });
            }

            Result.Data                = new ListMessageResult();
            Result.Data.Chats          = chatsResult;
            Result.Data.NumberNext     = nbNext;
            Result.Data.DatePrevious   = datePrevious;
            Result.Data.NumberPrevious = nbPrevious;
            Result.Data.DateNext       = dateNext;
        }