Пример #1
0
        public async Task <IActionResult> ActiveNextSession(string Id)
        {
            OpenOfficeHoursViewModel model = new OpenOfficeHoursViewModel();

            if (!string.IsNullOrEmpty(Id))
            {
                var openHoursModel = await _openOfficeHoursService.getOpenHoursAsync(Id);

                if (openHoursModel != null && openHoursModel.IsMeetingTokenUsed == false)
                {
                    //DateTime nextMeetingDate = openHoursModel.OFromDate.AddDays(7);

                    model.UserId       = openHoursModel.CreatedBy;
                    model.MaxAttendees = openHoursModel.MaxAttendees;
                    model.ODescription = openHoursModel.ODescription;
                    model.OFrequency   = openHoursModel.OFrequency;
                    TimeSpan difference = DateTime.Now.Date - openHoursModel.OFromDate.Date;
                    if (difference.Days > 7)
                    {
                        model.OFromDate = SphixHelper.setDateFromDayName(openHoursModel.OTimeDayName, DateTime.Now.Date);
                    }
                    else if (difference.Days == 0)
                    {
                        model.OFromDate = openHoursModel.OFromDate;
                    }
                    else
                    {
                        model.OFromDate = SphixHelper.setDateFromDayName(openHoursModel.OTimeDayName, openHoursModel.OFromDate);
                    }
                    // model.OFromDate = nextMeetingDate;
                    model.OTimeZone        = openHoursModel.OTimeZone;
                    model.OTime            = openHoursModel.OTime;
                    model.OToDate          = model.OFromDate;// openHoursModel.OToDate;
                    model.OName            = openHoursModel.OName;
                    model.OTime            = openHoursModel.OTime;
                    model.OTitle           = openHoursModel.OTitle;
                    model.WhoCanAttend     = openHoursModel.WhoCanAttend;
                    model.OTimeDayName     = openHoursModel.OTimeDayName;
                    model.CommunityGroupId = openHoursModel.CommunityGroups.Id;
                    string token = Guid.NewGuid().ToString().Replace("-", "");
                    model.NextMeetingToken = token;
                    model.IsFirstMeeting   = false;
                    model.LastSessionId    = openHoursModel.Id;
                    var _existingTable = await _openOfficeHoursService.CheckTableIsExist(model.UserId, model.CommunityGroupId, model.OTimeZone, model.OFromDate);

                    if (_existingTable.Status)
                    {
                        return(Json(_existingTable));
                    }
                    var _result = await _openOfficeHoursService.SaveOpenHoursAsync(model, null, null);

                    if (_result.Status)
                    {
                        await _openOfficeHoursService.UpdateNextMeetingToken(openHoursModel.Id);

                        //IsMeetingTokenUsed
                        var pathToFile = _env.WebRootPath
                                         + Path.DirectorySeparatorChar.ToString()
                                         + "Templates"
                                         + Path.DirectorySeparatorChar.ToString()
                                         + "EmailTemplates"
                                         + Path.DirectorySeparatorChar.ToString()
                                         + "OpenHoursMeetingCreateNewTable.html";
                        string HtmlBody = string.Empty;
                        using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
                        {
                            HtmlBody = SourceReader.ReadToEnd();
                        }
                        var callbackUrl = Url.Action("ActiveNextSession", "CommunityOpenOfficeHours", null, protocol: HttpContext.Request.Scheme) + "/" + token;
                        await _openHoursMailService.SendMailOnCreateNewTableAsync(model.UserId, token, callbackUrl, HtmlBody, model.OFromDate.ToShortDateString() + " at " + model.OTime + " " + model.OTimeZone);

                        //send thanks mail
                    }
                }
                else
                {
                    model.IsMeetingTokenUsed = true;
                }
            }
            return(View(model));
        }
Пример #2
0
        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
                });
            }
        }