private async Task <BaseModel> Update(CommunityGroupViewModel model) { CommunityGroupsDataModel communityGroupModel = await _unitOfWork.UserCommunityGroupsRepository.GetByID(model.Id); try { communityGroupModel.Title = model.Title; communityGroupModel.Description = model.Description; if (!string.IsNullOrEmpty(model.DescriptionVideoUrl)) { await _awsS3Bucket.DeleteFileAsync(communityGroupModel.DescriptionVideoUrl); communityGroupModel.DescriptionVideoUrl = model.DescriptionVideoUrl; } communityGroupModel.CommunityGroupURL = Urlhelper.GenerateSeoFriendlyURL(model.Title); //communityGroupModel.IsActive = true; //communityGroupModel.IsPublish = true; communityGroupModel.IsPublicGroup = model.IsPublicGroup; communityGroupModel.AddedDate = DateTime.Now; communityGroupModel.CommunityId = model.OgranizationsId; await _unitOfWork.UserCommunityGroupsRepository.Update(communityGroupModel); //if group is not public then data will save in relation tables if (!model.IsPublicGroup) { //saving data in relation tables await SaveCommunityTargetedGroupsAsync(model.CommunityTargetedGroupId, communityGroupModel.User, communityGroupModel); await SaveCommunityTargetedAssociationAsync(model.AssociationId, communityGroupModel.User, communityGroupModel); //await SaveCommunityTargetedType1Async(model.Type1Id, communityGroupModel.User, communityGroupModel); //await SaveCommunityTargetedType2Async(model.Type2Id, communityGroupModel.User, communityGroupModel); await SaveCommunityTargetedInterestsAsync(model.TargetedInterestIds, communityGroupModel.User, communityGroupModel); } await SaveCommunityGroupsThemeAsync(model.ThemesId, communityGroupModel.User, communityGroupModel); //SaveOpenHours OpenOfficeHoursViewModel OpenOfficeHoursModel = JsonConvert.DeserializeObject <OpenOfficeHoursViewModel>(model.OpenOfficeHours); //OpenOfficeHoursModel.OFromDate = SphixHelper.setDateFromDayName(OpenOfficeHoursModel.OTimeDayName, DateTime.Now.Date); //OpenOfficeHoursModel.OToDate = OpenOfficeHoursModel.OFromDate; await _openOfficeHoursService.SaveOpenHoursAsync(OpenOfficeHoursModel, communityGroupModel.User, communityGroupModel); return(new BaseModel { Status = true, Id = communityGroupModel.Id, Messsage = UMessagesInfo.RecordSaved }); } catch (Exception ex) { return(new BaseModel { Status = false, Messsage = UMessagesInfo.Error }); } }
public async Task <BaseModel> SaveAsync(ArticleViewModel model, IFormFile articleShareDocument) { try { //save with attcahed doc BaseModel baseModel = new BaseModel(); string articeDocUrl = string.Empty; string articleFolderPath = "ArcticlesShareDocuments/" + DateTime.Now.Year.ToString(); string articleFileName = string.Empty; if (articleShareDocument != null && articleShareDocument.Length > 0) { articleFileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(articleShareDocument.FileName); articeDocUrl = articleFolderPath + "/" + articleFileName; model.ShareDocument = articeDocUrl; } if (model.Id == 0) { UsersLoginDataModel _user = await _unitOfWork.UserLoginRepository.GetByID(model.UserId); CommunityGroupsDataModel communityGroupsData = await _unitOfWork.UserCommunityGroupsRepository.GetByID(model.CommunityGroupsId); baseModel = await Save(model, _user, communityGroupsData); } else { baseModel = await Update(model); } if (baseModel.Status == true) { if (articleShareDocument != null && articleShareDocument.Length > 0) { await _awsS3Bucket.UploadFileAsync(articleFolderPath, articleShareDocument, articleFileName); } } return(baseModel); } catch (Exception) { return(new BaseModel { Status = false, Messsage = UMessagesInfo.Error }); } }
public async Task <BaseModel> PublishCommunityGroupAsync(long Id, bool IsPublish) { try { CommunityGroupsDataModel communityGroupModel = await _unitOfWork.UserCommunityGroupsRepository.GetByID(Id); communityGroupModel.IsPublish = IsPublish; await _unitOfWork.UserCommunityGroupsRepository.Update(communityGroupModel); return(new BaseModel { Status = true, Id = communityGroupModel.Id, Messsage = UMessagesInfo.RecordSaved }); } catch (Exception) { return(new BaseModel { Status = false, Messsage = UMessagesInfo.Error }); } }
public async Task <BaseModel> SaveEventAsync(LiveEventViewModel model) { if (string.IsNullOrEmpty(model.ETime)) { return(new BaseModel { Status = false, Messsage = "Please set the event time." }); } model.EName = model.ETitle; if (model.Id == 0) { UsersLoginDataModel _user = await _unitOfWork.UserLoginRepository.GetByID(model.UserId); CommunityGroupsDataModel communityGroupsData = await _unitOfWork.UserCommunityGroupsRepository.GetByID(model.CommunityGroupId); return(await Save(model, _user, communityGroupsData)); } else { return(await Update(model)); } }
/// <summary> /// Save and update data in Open Office Hours table /// </summary> /// <param name="model"></param> /// <param name="user">if user model is null then please pass UserId into the OpenOfficeHoursViewModel</param> /// <param name="communityGroupsData">if communityGroupsData model is null then please pass CommunityGroupId into the OpenOfficeHoursViewModel</param> /// <returns></returns> public async Task <BaseModel> SaveOpenHoursAsync(OpenOfficeHoursViewModel model, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { if (user == null) { user = await _unitOfWork.UserLoginRepository.GetByID(model.UserId); } if (communityGroupsData == null) { communityGroupsData = await _unitOfWork.UserCommunityGroupsRepository.GetByID(model.CommunityGroupId); } if (model.Id == 0) { CommunityOpenOfficeHours dataModel = new CommunityOpenOfficeHours { CreatedBy = user.Id, User = user, CommunityGroups = communityGroupsData, OTitle = model.OTitle, OName = model.OName, ODescription = model.ODescription, OFrequency = model.OFrequency, OFromDate = model.OFromDate, // setDateFromDayName(model.OTimeDayName, model.OFromDate), OToDate = model.OFromDate, // setDateFromDayName(model.OTimeDayName, model.OFromDate), OTime = model.OTime, OTimeDayName = model.OTimeDayName, OTimeZone = model.OTimeZone, MaxAttendees = model.MaxAttendees, WhoCanAttend = model.WhoCanAttend, IsActive = true, IsFirstMeeting = model.IsFirstMeeting, NextMeetingToken = model.NextMeetingToken, LastSessionId = model.LastSessionId, AddHours = model.AddHours }; await _unitOfWork.UserCommunityOpenOfficeHoursRepository.Insert(dataModel); if (model.AddHours) { await _context.LoadStoredProc("AddHoursInOpenOfficeHours") .WithSqlParam("Id", dataModel.Id) .ExecuteStoredProcAsync((handler) => { // do something with your results. }); } return(new BaseModel { Status = true, Id = dataModel.Id, Messsage = UMessagesInfo.RecordSaved }); } else { var openOfficeHoursModel = await _unitOfWork.UserCommunityOpenOfficeHoursRepository.GetByID(model.Id); openOfficeHoursModel.OTitle = model.OTitle; openOfficeHoursModel.OName = model.OName; openOfficeHoursModel.ODescription = model.ODescription; openOfficeHoursModel.OFrequency = model.OFrequency; if (openOfficeHoursModel.OTimeDayName.ToLower().Trim() != model.OTimeDayName.ToLower().Trim()) { openOfficeHoursModel.OFromDate = SphixHelper.setDateFromDayName(model.OTimeDayName, DateTime.Now.Date); openOfficeHoursModel.OToDate = openOfficeHoursModel.OFromDate; } else { openOfficeHoursModel.OFromDate = model.OFromDate;// setDateFromDayName(model.OTimeDayName, model.OFromDate); openOfficeHoursModel.OToDate = openOfficeHoursModel.OFromDate; } openOfficeHoursModel.OTime = model.OTime; openOfficeHoursModel.OTimeDayName = model.OTimeDayName; openOfficeHoursModel.OTimeZone = model.OTimeZone; openOfficeHoursModel.MaxAttendees = model.MaxAttendees; openOfficeHoursModel.WhoCanAttend = model.WhoCanAttend; openOfficeHoursModel.IsActive = true; //openOfficeHoursModel.AddHours = model.AddHours; //openOfficeHoursModel.IsFirstMeeting = model.IsFirstMeeting; await _unitOfWork.UserCommunityOpenOfficeHoursRepository.Update(openOfficeHoursModel); return(new BaseModel { Status = true, Id = model.Id, Messsage = UMessagesInfo.RecordSaved }); } }
private async Task <BaseModel> Save(ArticleViewModel model, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { CommunityArticles dataModel = new CommunityArticles { CreatedBy = model.UserId, User = user, CommunityGroups = communityGroupsData, Title = model.ArticleTitle, Description = model.ArticleDescription, ShareDocUrl = model.ShareDocument, IsActive = true, }; await _unitOfWork.UserCommunityArticlesRepository.Insert(dataModel); return(new BaseModel { Status = true, Id = dataModel.Id, Messsage = UMessagesInfo.RecordSaved }); }
public GroupEmailInvitationDataModel() { LastUpdate = DateTime.Now; SentByUser = new UsersLoginDataModel(); CommunityGroup = new CommunityGroupsDataModel(); }
public JoinCommunityGroupDataModel() { CommunityGroup = new CommunityGroupsDataModel(); User = new UsersLoginDataModel(); JoinDateTime = DateTime.Now; }
private async Task <BaseModel> Save(LiveEventViewModel model, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { CommunityLiveEvents dataModel = new CommunityLiveEvents { CreatedBy = model.UserId, User = user, CommunityGroups = communityGroupsData, ETitle = model.ETitle, EName = model.EName, EDescription = model.EDescription, EFrequency = model.EFrequency, EFromDate = model.EFromDate, EToDate = model.EToDate, ETime = model.ETime, ETimeDayName = model.ETimeDayName, ETimeZone = model.ETimeZone, MaxAttendees = model.MaxAttendees, Observers = model.Observers, WhoCanAttend = model.WhoCanAttend, Participants = model.Participants, Picture = model.Picture, IsActive = true, IsSingleEvent = model.IsSingleEvent }; await _unitOfWork.UserCommunityLiveEventsRepository.Insert(dataModel); return(new BaseModel { Status = true, Id = dataModel.Id, Messsage = UMessagesInfo.RecordSaved }); }
private async Task <bool> SaveCommunityGroupsThemeAsync(string themesId, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { string[] themes = themesId.Split(','); var communityGroupTheme = await _unitOfWork.UserCommunityGroupThemeRepository.FindAllBy(c => c.CommunityGroups == communityGroupsData); foreach (var themeItem in communityGroupTheme) { if (themes.Contains(themeItem.CommunityTargetedGroupId.ToString()) == false) { themeItem.IsActive = false; } else { themeItem.IsActive = true; themes = themes.Where(val => val != themeItem.CommunityTargetedGroupId.ToString()).ToArray(); } await _unitOfWork.UserCommunityGroupThemeRepository.Update(themeItem); } foreach (var item in themes) { if (!string.IsNullOrEmpty(item)) { UserCommunityGroupThemeDataModel userCommunities = new UserCommunityGroupThemeDataModel(); userCommunities.User = user; userCommunities.IsActive = true; userCommunities.CommunityGroups = communityGroupsData; userCommunities.CommunityTargetedGroupId = Convert.ToInt32(item); await _unitOfWork.UserCommunityGroupThemeRepository.Insert(userCommunities); } //Console.WriteLine(item); } themes = null; return(true); }
private async Task <bool> SaveCommunityTargetedInterestsAsync(string InterestsIds, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { string[] interests = InterestsIds.Split(','); var targetData = await _unitOfWork.UserCommunityTargetedInterestRepository.FindAllBy(c => c.CommunityGroups == communityGroupsData); foreach (var updateItem in targetData) { if (interests.Contains(updateItem.InterestId.ToString()) == false) { updateItem.IsActive = false; } else { updateItem.IsActive = true; interests = interests.Where(val => val != updateItem.InterestId.ToString()).ToArray(); } await _unitOfWork.UserCommunityTargetedInterestRepository.Update(updateItem); } foreach (var item in interests) { if (!string.IsNullOrEmpty(item)) { UserCommunityTargetedInterestsDataModel interest = new UserCommunityTargetedInterestsDataModel(); interest.User = user; interest.CommunityGroups = communityGroupsData; interest.InterestId = Convert.ToInt32(item); interest.IsActive = true; await _unitOfWork.UserCommunityTargetedInterestRepository.Insert(interest); } //Console.WriteLine(item); } interests = null; return(true); }
private async Task <bool> SaveCommunityTargetedType2Async(string type2Ids, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { string[] type2s = type2Ids.Split(','); var targetData = await _unitOfWork.UserCommunityTargetedType2Repository.FindAllBy(c => c.CommunityGroups == communityGroupsData); foreach (var updateItem in targetData) { if (type2s.Contains(updateItem.TypeId.ToString()) == false) { updateItem.IsActive = false; } else { updateItem.IsActive = true; type2s = type2s.Where(val => val != updateItem.TypeId.ToString()).ToArray(); } await _unitOfWork.UserCommunityTargetedType2Repository.Update(updateItem); } foreach (var item in type2s) { if (!string.IsNullOrEmpty(item)) { UserCommunityTargetedType2DataModel type2 = new UserCommunityTargetedType2DataModel(); type2.User = user; type2.CommunityGroups = communityGroupsData; type2.TypeId = Convert.ToInt32(item); type2.IsActive = true; await _unitOfWork.UserCommunityTargetedType2Repository.Insert(type2); } //Console.WriteLine(item); } type2s = null; return(true); }
private async Task <bool> SaveCommunityTargetedAssociationAsync(string associationIds, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { string[] associations = associationIds.Split(','); var targetData = await _unitOfWork.UserCommunityTargetedAssociationsRepository.FindAllBy(c => c.CommunityGroups == communityGroupsData); foreach (var updateItem in targetData) { if (associations.Contains(updateItem.AssociationId.ToString()) == false) { updateItem.IsActive = false; } else { updateItem.IsActive = true; associations = associations.Where(val => val != updateItem.AssociationId.ToString()).ToArray(); } await _unitOfWork.UserCommunityTargetedAssociationsRepository.Update(updateItem); } foreach (var item in associations) { if (!string.IsNullOrEmpty(item)) { UserCommunityTargetedAssociationsDataModel userAssociation = new UserCommunityTargetedAssociationsDataModel(); userAssociation.User = user; userAssociation.CommunityGroups = communityGroupsData; userAssociation.AssociationId = Convert.ToInt32(item); userAssociation.IsActive = true; await _unitOfWork.UserCommunityTargetedAssociationsRepository.Insert(userAssociation); } //Console.WriteLine(item); } associations = null; return(true); }
private async Task <BaseModel> Save(CommunityGroupViewModel model, UsersLoginDataModel user, string articeDoclUrl) { try { if (string.IsNullOrEmpty(model.TargetedInterestIds) && model.IsPublicGroup == false) { return(new BaseModel { Status = false, Messsage = "Please select Interest" }); } CommunityGroupsDataModel communityGroupModel = new CommunityGroupsDataModel { CreatedBy = model.UserId, User = user, Title = model.Title, CommunityGroupURL = Urlhelper.GenerateSeoFriendlyURL(model.Title), Description = model.Description, DescriptionVideoUrl = model.DescriptionVideoUrl, IsActive = true, IsPublish = false, IsPublicGroup = model.IsPublicGroup, CommunityId = model.OgranizationsId }; await _unitOfWork.UserCommunityGroupsRepository.Insert(communityGroupModel); //if group is not public then data will save in relation tables if (!model.IsPublicGroup) { //saveing data in relation tables await SaveCommunityTargetedGroupsAsync(model.CommunityTargetedGroupId, user, communityGroupModel); await SaveCommunityTargetedAssociationAsync(model.AssociationId, user, communityGroupModel); //await SaveCommunityTargetedType1Async(model.Type1Id, user, communityGroupModel); //await SaveCommunityTargetedType2Async(model.Type2Id, user, communityGroupModel); await SaveCommunityTargetedInterestsAsync(model.TargetedInterestIds, user, communityGroupModel); } await SaveCommunityGroupsThemeAsync(model.ThemesId, user, communityGroupModel); //SaveOpenHours OpenOfficeHoursViewModel OpenOfficeHoursModel = JsonConvert.DeserializeObject <OpenOfficeHoursViewModel>(model.OpenOfficeHours); OpenOfficeHoursModel.OFromDate = SphixHelper.setDateFromDayName(OpenOfficeHoursModel.OTimeDayName, DateTime.Now.Date); OpenOfficeHoursModel.OToDate = OpenOfficeHoursModel.OFromDate; OpenOfficeHoursModel.IsFirstMeeting = true; await _openOfficeHoursService.SaveOpenHoursAsync(OpenOfficeHoursModel, user, communityGroupModel); //SaveLiveEvent LiveEventViewModel LiveEventModel = JsonConvert.DeserializeObject <LiveEventViewModel>(model.LiveEvent); await SaveLiveEvent(LiveEventModel, user, communityGroupModel); //SaveArticles ArticleViewModel ArticleModel = JsonConvert.DeserializeObject <ArticleViewModel>(model.Article); ArticleModel.ShareDocument = articeDoclUrl; await SaveArticles(ArticleModel, user, communityGroupModel); return(new BaseModel { Status = true, Id = communityGroupModel.Id, Messsage = UMessagesInfo.RecordSaved }); } catch (Exception ex) { return(new BaseModel { Status = false, Messsage = UMessagesInfo.Error }); } }