Пример #1
0
        public static bool ModifyUserCalendar(UserCalendar model)
        {
            string sql = string.Format(@"update {0} set [CompanyId]=@CompanyId,[CompanyName]=@CompanyName,[Name]=@Name,[StartDate]=@StartDate,[EndDate]=@EndDate,[UserId]=@UserId,[Type]=@Type,[PId]=@PId,[Status]=@Status,[ModifyDate]=getdate(),[ModifyBy]=@ModifyBy,[Title]=@Title
            where Id=@Id", TableName);

            return(DBAccess.ExecuteSqlWithEntity(sql, model));
        }
Пример #2
0
    protected void btnDeleteActivity_Click(object sender, EventArgs e)
    {
        string activityId = hfCurrentActivity.Value;
        var    activity   = EntityFactory.GetById <Activity>(activityId);

        if (activity == null)
        {
            return;
        }

        if ((activity.Recurring) && (hfCurrentActivityIsOccurence.Value == "true"))
        {
            DateTime recurDate = DateTime.Parse(hfOccurrenceDate.Value);
            Link.DeleteActivityOccurrencePrompt(activityId, recurDate);
        }
        else
        {
            var cal = UserCalendar.GetCurrentUserCalendarList().First <UserCalendar>(uc => uc.CalUserId == activity.UserId);
            if (cal.AllowDelete == false)
            {
                throw new ValidationException(GetLocalResourceObject("DoNotHaveRightsToDeleteActivity").ToString());
            }
            else
            {
                activity.Delete();
            }
        }
    }
Пример #3
0
                public void EmitsFalseAfterAllTheCalendarsHaveBeenDeselected()
                {
                    var observer = Substitute.For <IObserver <bool> >();

                    ViewModel.DoneAction.Enabled.Subscribe(observer);
                    var selectedableUserCalendars = Enumerable
                                                    .Range(0, 10)
                                                    .Select(id =>
                    {
                        var userCalendar = new UserCalendar(id.ToString(), id.ToString(), "Doenst matter");
                        return(new SelectableUserCalendarViewModel(userCalendar, false));
                    });

                    //Select all the calendars
                    selectedableUserCalendars
                    .ForEach(calendar => ViewModel.SelectCalendarAction.Execute(calendar).Wait());
                    //Deselect all the calendars
                    selectedableUserCalendars
                    .ForEach(calendar => ViewModel.SelectCalendarAction.Execute(calendar).Wait());
                    SchedulerProvider.TestScheduler.AdvanceBy(3);

                    Received.InOrder(() =>
                    {
                        observer.OnNext(false);
                        observer.OnNext(true);
                        observer.OnNext(false);
                    });
                }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     m_SLXUserService = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService;
     _UserId          = m_SLXUserService.GetUser().Id.ToString();
     _UserOptions     = ActivityAlarmOptions.Load(Server.MapPath(@"App_Data\LookupValues"));
     if (!IsPostBack)
     {
         IList <IUser> users = UserCalendar.GetCalendarUsers(_UserId);
         foreach (IUser item in users)
         {
             if (_UserId.Equals(item.Id))
             {
                 UserList.Items.Insert(0, new ListItem(item.ToString(), item.Id.ToString()));
                 UserList.SelectedIndex = 0;
             }
             else
             {
                 if (item.Id.ToString().ToUpper().Trim() != "ADMIN")
                 {
                     UserList.Items.Add(new ListItem(item.ToString(), item.Id.ToString()));
                 }
             }
         }
     }
     if (UserList.SelectedIndex == -1)
     {
         UserList.SelectedIndex = 0;
     }
     GetContext();
 }
Пример #5
0
    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (!Visible)
        {
            return;
        }

        DateTime fromDate = GetLastWebUpdate();

        SearchOptions.UserIds.AddRange(UserCalendar.GetCalendarAccessUserList(CurrentUserId));
        SearchOptions.StartDate = fromDate;
        if (!String.IsNullOrEmpty(grdNewActivities.SortExpression))
        {
            SearchOptions.OrderBy = grdNewActivities.SortExpression;
        }
        SearchOptions.IncludeUnconfirmed = true;
        SearchOptions.MaxResults         = grdNewActivities.PageSize;

        grdNewActivities.DataSource = ActivitiesNewObjectDataSource;
        grdNewActivities.DataBind();
        grdModifiedActivities.DataSource = ActivitiesModifiedObjectDataSource;
        grdModifiedActivities.DataBind();
    }
    protected void btnComplete_Click(object sender, EventArgs e)
    {
        string            key              = hfSelections.Value;
        bool              completeAll      = true;
        ISelectionService srv              = SelectionServiceRequest.GetSelectionService();
        ISelectionContext selectionContext = srv.GetSelectionContext(key);
        List <string>     ids              = selectionContext.GetSelectedIds();

        foreach (string id in ids)
        {
            ILitRequest lit = EntityFactory.GetById <ILitRequest>(id);

            if (UserCalendar.CurrentUserCanEdit(lit.CreateUser))
            {
                lit.CompleteLitRequest();
            }
            else
            {
                completeAll = false;
            }
        }
        // this has to occur after the fulfillment is completed.  The status needs to be updated before refresh is called.
        ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true);

        if (!completeAll)
        {
            DialogService.ShowMessage(GetLocalResourceObject("Err_Complete").ToString(), 70, 400);
        }
    }
                public void DoesNotEmitAnythingWhenSelectingAdditionalCalendars()
                {
                    var observer = Substitute.For <IObserver <bool> >();

                    ViewModel.Done.Enabled.Subscribe(observer);
                    var selectedableUserCalendars = Enumerable
                                                    .Range(0, 10)
                                                    .Select(id =>
                    {
                        var userCalendar = new UserCalendar(id.ToString(), id.ToString(), "Doenst matter");
                        return(new SelectableUserCalendarViewModel(userCalendar, false));
                    });

                    var auxObserver = TestScheduler.CreateObserver <Unit>();

                    ViewModel.SelectCalendar.ExecuteSequentally(selectedableUserCalendars)
                    .Subscribe(auxObserver);

                    TestScheduler.Start();

                    Received.InOrder(() =>
                    {
                        observer.OnNext(false);
                        observer.OnNext(true);
                    });
                }
Пример #8
0
    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
    protected override void OnPreRender(EventArgs e)
    {
        if (!Visible)
        {
            return;
        }

        DateTime            fromDate    = DateTime.UtcNow;
        IUserOptionsService userOptions = ApplicationContext.Current.Services.Get <IUserOptionsService>();

        if (userOptions != null)
        {
            try
            {
                fromDate = DateTime.Parse(userOptions.GetCommonOption("LastWebUpdate", "Web", false, fromDate.ToString(), "LastWebUpdate"));
            }
            catch
            { }
        }

        SearchOptions.NotesOnly  = true;
        SearchOptions.SearchDate = fromDate;
        SearchOptions.UserIds.AddRange(UserCalendar.GetCalendarAccessUserList(CurrentUserId));

        //New History
        SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.New;
        if (!String.IsNullOrEmpty(grdNewNotes.SortExpression))
        {
            SearchOptions.OrderBy       = grdNewNotes.SortExpression;
            SearchOptions.SortDirection =
                (grdNewNotes.CurrentSortDirection.Equals("Ascending", StringComparison.CurrentCultureIgnoreCase))
                    ? ListSortDirection.Ascending
                    : ListSortDirection.Descending;
        }
        WNRequest.SearchOptions = SearchOptions;
        grdNewNotes.DataSource  = NotesNewObjectDataSource;
        grdNewNotes.DataBind();

        //Modified History
        SearchOptions.SearchType = WhatsNewSearchOptions.SearchTypeEnum.Updated;
        if (!String.IsNullOrEmpty(grdModifiedNotes.SortExpression))
        {
            SearchOptions.OrderBy       = grdModifiedNotes.SortExpression;
            SearchOptions.SortDirection =
                (grdModifiedNotes.CurrentSortDirection.Equals("Ascending", StringComparison.CurrentCultureIgnoreCase))
                    ? ListSortDirection.Ascending
                    : ListSortDirection.Descending;
        }
        else
        {
            SearchOptions.OrderBy       = "ModifyDate";
            SearchOptions.SortDirection = ListSortDirection.Ascending;
        }
        WNRequest.SearchOptions     = SearchOptions;
        grdModifiedNotes.DataSource = NotesModifiedObjectDataSource;
        grdModifiedNotes.DataBind();

        base.OnPreRender(e);
    }
Пример #9
0
 private void BindUserList()
 {
     UserList.DataBind(
         from UserCalendar uc in UserCalendar.GetCurrentUserCalendarList()
         let key                         = uc.UserName
                               let value = uc.CalUser.UserName.ToUpper().Trim()
                                           select new KeyValuePair <string, string>(key, value));
     UserList.SelectedValue = SlxWebScheduleInfo.ActiveResourceName;
 }
        public SelectableUserCalendarViewModel(UserCalendar calendar, bool selected)
        {
            Ensure.Argument.IsNotNull(calendar, nameof(calendar));

            Id         = calendar.Id;
            Name       = calendar.Name;
            SourceName = calendar.SourceName;
            Selected   = selected;
        }
        public async Task AddCalendar(long userId, Calendar calendar)
        {
            var user = await context.Users.FindAsync(userId);

            var userCalendar = new UserCalendar {
                CalendarId = calendar.Id, UserId = userId
            };

            user.UserCalendars.Add(userCalendar);
            await context.SaveChangesAsync();
        }
        public IActionResult RemoveFromCalendar(int ID)
        {
            var          user      = userManager.GetUserAsync(HttpContext.User).Result;
            var          events    = context.Events.ToList();
            Event        _e        = events.FirstOrDefault(x => x.EventID == ID);
            var          calendars = context.Calendars;
            UserCalendar c         = calendars.FirstOrDefault(x => x.EventID == ID && x.UserID == user.UserName);

            calendars.Remove(c);
            context.SaveChanges();
            ViewBag.user = userManager.GetUserAsync(HttpContext.User).Result;
            return(RedirectToAction("EventList"));
        }
    /// <summary>
    /// Gets the current user calendar list.
    /// </summary>
    /// <param name="CurrentUserID">The current user ID.</param>
    /// <returns></returns>
    private List <UserCalendar> GetCurrentUserCalendarList(string CurrentUserID)
    {
        List <UserCalendar> calList = null;

        if (IsActivity() || IsHistory())
        {
            calList = UserCalendar.GetCalendarAccessList(CurrentUserID);
            if (calList != null)
            {
                UserCalendarComparer ucc = new UserCalendarComparer();
                calList.Sort(ucc);
            }
        }
        return(calList);
    }
Пример #14
0
            public async Task StoresTheEnabledCalendarsInUserPreferences()
            {
                var firstCalendar  = new UserCalendar("1", "1", "1");
                var secondCalendar = new UserCalendar("2", "2", "2");

                await ViewModel.SelectCalendarAction.Execute(new SelectableUserCalendarViewModel(firstCalendar, false));

                await ViewModel.SelectCalendarAction.Execute(new SelectableUserCalendarViewModel(secondCalendar, false));

                Received.InOrder(() =>
                {
                    UserPreferences.SetEnabledCalendars(new string[] { "1" });
                    UserPreferences.SetEnabledCalendars(new string[] { "1", "2" });
                });
            }
        public IActionResult AddToCalendar(int ID)
        {
            var          events    = context.Events.ToList();
            Event        _e        = events.FirstOrDefault(x => x.EventID == ID);
            var          calendars = context.Calendars;
            UserCalendar c         = new UserCalendar
            {
                UserID  = userManager.GetUserAsync(HttpContext.User).Result.UserName,
                EventID = _e.EventID
            };

            calendars.Add(c);
            context.SaveChanges();
            ViewBag.user = userManager.GetUserAsync(HttpContext.User).Result;
            return(RedirectToAction("EventList"));
        }
Пример #16
0
 public IActionResult PostAttendanceDataJson([FromBody] UserCalendar cal)
 {
     try
     {
         bool success = false;
         int  ret     = _ICalendar.UserCalendarMarkAttendance(cal);
         if (ret > 0)
         {
             success = true;
         }
         return(Json(new { success = success }));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
            public async Task ReturnsSuggestionsSortedByABSOffsetFromNow()
            {
                var now = new DateTimeOffset(2020, 1, 2, 3, 4, 5, TimeSpan.Zero);

                TimeService.CurrentDateTime.Returns(now);
                var tenMinutes = TimeSpan.FromMinutes(10);
                var events     = Enumerable.Range(1, 5)
                                 .Select(id => new CalendarItem(
                                             id.ToString(),
                                             CalendarItemSource.Calendar,
                                             id % 2 == 0 ? now - tenMinutes * id : now + tenMinutes * id,
                                             tenMinutes,
                                             id.ToString(),
                                             CalendarIconKind.None));

                var expectedSuggestionIds = new List <string>
                {
                    "1",
                    "2",
                    "3",
                    "4",
                    "5"
                };

                var userCalendar = new UserCalendar(
                    "",
                    "",
                    "",
                    true);

                CalendarService
                .GetEventsInRange(Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>())
                .Returns(Observable.Return(events));

                InteractorFactory.GetUserCalendars().Execute()
                .Returns(Observable.Return(new List <UserCalendar> {
                    userCalendar
                }));

                var suggestions = await Provider.GetSuggestions().ToList();

                await CalendarService.Received().GetEventsInRange(now.AddHours(-1), now.AddHours(1));

                suggestions.Should().HaveCount(1)
                .And.OnlyContain(suggestion => expectedSuggestionIds.Any(expectedId => expectedId == suggestion.Description));
            }
    /// <summary>
    /// Gets the user calendar.
    /// </summary>
    /// <returns></returns>
    private UserCalendar GetUserCalendar()
    {
        UserCalendar userCalendar = null;

        if (IsActivity())
        {
            Activity currentActivity = CurrentActivity();
            if (currentActivity != null)
            {
                List <UserCalendar> calList = GetCurrentUserCalendarList(CurrentUserId);
                if (calList != null)
                {
                    foreach (UserCalendar uc in calList)
                    {
                        if (uc.CalUser.Id.ToString().Trim().Equals(currentActivity.UserId.Trim()))
                        {
                            userCalendar = uc;
                            break;
                        }
                    }
                }
            }
        }
        else if (IsHistory())
        {
            History currentHistory = CurrentHistory();
            if (currentHistory != null)
            {
                List <UserCalendar> calList = GetCurrentUserCalendarList(CurrentUserId);
                if (calList != null)
                {
                    foreach (UserCalendar uc in calList)
                    {
                        if (uc.CalUser.Id.ToString().Trim().Equals(currentHistory.UserId.Trim()))
                        {
                            userCalendar = uc;
                            break;
                        }
                    }
                }
            }
        }

        return(userCalendar);
    }
 /// <summary>
 /// Updates the UI for calendar security.
 /// </summary>
 private void UpdateUIForCalendarSecurity()
 {
     if (IsActivity() || IsHistory())
     {
         UserCalendar userCalendar = GetUserCalendar();
         if (userCalendar != null)
         {
             if (!((bool)userCalendar.AllowEdit))
             {
                 DisableFormControls();
             }
         }
         else
         {
             DisableFormControls();
         }
     }
 }
Пример #20
0
    /// <summary>
    /// Binds the leader list to the current user's calendar access list.
    /// Inserts the user calendar for the selected user if it does not exist. This case would occur if
    /// the current user does not have access to the selected user's calendar.
    /// </summary>
    /// <param name="list">The list of user calendars.</param>
    /// <param name="selectedUserId">The selected user id.</param>
    public static void BindLeaderList(DropDownList list, string selectedUserId)
    {
        if (list.Items.Count > 1)
        {
            return;                       // already loaded
        }
        list.Items.Clear();
        bool selectedUserInList          = false;
        List <UserCalendar> userCalendar = UserCalendar.GetCurrentUserCalendarList();

        foreach (UserCalendar uc in userCalendar)
        {
            if (uc.AllowAdd.HasValue && uc.AllowAdd.Value) // == true
            {
                if (uc.UserId.ToUpper().Trim() == selectedUserId.ToUpper().Trim())
                {
                    selectedUserInList = true;
                }
                ListItem listItem = new ListItem(uc.UserName, uc.CalUser.Id.ToString());
                list.Items.Add(listItem);
            }
        }
        UserCalendar suc = UserCalendar.GetUserCalendarById(selectedUserId);

        if (suc != null)
        {
            //Verify that we have the exact right userid.  i.e. 'ADMIN    ' may be trimmed to 'ADMIN'
            selectedUserId = suc.CalUser.Id.ToString();
            if (!selectedUserInList)
            {
                ListItem newItem = new ListItem(suc.UserName, suc.CalUser.Id.ToString());
                list.Items.Add(newItem);
            }
        }

        ListItem selected = list.Items.FindByValue(selectedUserId);

        if (selected == null)
        {
            selected = new ListItem(selectedUserId, selectedUserId);
            list.Items.Add(selected);
        }
        list.SelectedIndex = list.Items.IndexOf(selected);
    }
Пример #21
0
 public IActionResult PostDataJson([FromBody] UserCalendar cal)
 {
     try
     {
         bool success = false;
         //Adding to adjust UTC
         cal.StartDate = cal.StartDate.AddHours(5.5);
         cal.EndDate   = cal.StartDate.AddHours(cal.Duration);
         int ret = _ICalendar.InsertUserCalendar(cal);
         if (ret > 0)
         {
             success = true;
         }
         return(Json(new { success = success }));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #22
0
        public int InsertUserCalendar(UserCalendar UserCalendar)
        {
            try {
                using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
                {
                    con.Open();
                    SqlTransaction sqltrans = con.BeginTransaction();
                    var            param    = new DynamicParameters();
                    param.Add("@TrainingId", UserCalendar.TrainingId);
                    param.Add("@PresenterId", UserCalendar.PresenterId);
                    param.Add("@Description", UserCalendar.Description);
                    param.Add("@StartDate", UserCalendar.StartDate);
                    param.Add("@EndDate", UserCalendar.EndDate);
                    var result = con.Query <int>("INSERT INTO Calendar VALUES(@TrainingId,@PresenterId,@Description,@StartDate,@EndDate,getutcdate(),getutcdate()); SELECT CAST(SCOPE_IDENTITY() as int);", param, sqltrans, true, 0, System.Data.CommandType.Text).Single();

                    if (result > 0)
                    {
                        UserCalendar.CalendarId = result;
                        foreach (var v in UserCalendar.Attendees)
                        {
                            var paramUserCalendar = new DynamicParameters();
                            paramUserCalendar.Add("@AttendeeId", v);
                            paramUserCalendar.Add("@CalendarId", UserCalendar.CalendarId);
                            var resultCalendar = con.Query <int>("INSERT INTO User_Calendar VALUES(@AttendeeId,@CalendarId,getutcdate(),getutcdate(),0); SELECT CAST(SCOPE_IDENTITY() as int);", paramUserCalendar, sqltrans, true, 0, System.Data.CommandType.Text).Single();
                        }
                        sqltrans.Commit();
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
            public async Task StoresTheEnabledCalendarsInUserPreferences()
            {
                var firstCalendar  = new UserCalendar("1", "1", "1");
                var secondCalendar = new UserCalendar("2", "2", "2");

                var observer = TestScheduler.CreateObserver <Unit>();

                ViewModel.SelectCalendar.ExecuteSequentally(
                    new SelectableUserCalendarViewModel(firstCalendar, false),
                    new SelectableUserCalendarViewModel(secondCalendar, false)
                    )
                .Subscribe(observer);


                TestScheduler.Start();

                Received.InOrder(() =>
                {
                    UserPreferences.SetEnabledCalendars(new string[] { "1" });
                    UserPreferences.SetEnabledCalendars(new string[] { "1", "2" });
                });
            }
Пример #24
0
        public int UserCalendarMarkAttendance(UserCalendar UserCalendar)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
                {
                    con.Open();
                    SqlTransaction sqltrans = con.BeginTransaction();
                    StringBuilder  Attendee = new StringBuilder();
                    Attendee.Append("(");
                    foreach (var v in UserCalendar.Attendees)
                    {
                        Attendee.Append(v + ",");
                    }
                    Attendee.Remove(Attendee.Length - 1, 1);
                    Attendee.Append(")");
                    var paramUserCalendar = new DynamicParameters();
                    //paramUserCalendar.Add("@AttendeeId", Attendee.ToString());
                    //paramUserCalendar.Add("@CalendarId", UserCalendar.CalendarId);
                    string sql            = "UPDATE User_Calendar SET Attended = 1 WHERE CalendarId = " + UserCalendar.CalendarId + " AND AttendeeId IN " + Attendee.ToString();
                    var    resultCalendar = con.Execute(sql, null, sqltrans, 0, System.Data.CommandType.Text);

                    if (resultCalendar > 0)
                    {
                        sqltrans.Commit();
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                    return(resultCalendar);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    public ActivityFormHelper(Activity activity)
    {
        Guard.ArgumentNotNull(activity, "activity");

        _Activity = activity;

        UserCalendar uc = UserCalendar.GetCurrentUserCalendar(_Activity.UserId);
        bool         foundUserCalendar = uc != null && uc.AllowAdd.HasValue && uc.AllowEdit.HasValue && uc.AllowDelete.HasValue;

        //If a user has been granted calendar access to another user,
        //grant Add/Edit/Delete permissions to everything except Personal Activities.
        bool viewPersonal = true;

        if (Activity.Type == ActivityType.atPersonal)
        {
            viewPersonal = Activity.UserId == CurrentUserId;
        }

        _IsAddAllowed      = foundUserCalendar && uc.AllowAdd.Value && viewPersonal;
        _IsEditAllowed     = (foundUserCalendar && uc.AllowEdit.Value && viewPersonal) || CurrentUserId.Equals("ADMIN");
        _IsDeleteAllowed   = (foundUserCalendar && uc.AllowDelete.Value && viewPersonal) || CurrentUserId.Equals("ADMIN");
        _IsCompleteAllowed = (foundUserCalendar && uc.AllowEdit.Value && viewPersonal) || _Activity.MemberOfAdminActivity;
    }
Пример #26
0
                public void DoesNotEmitAnythingWhenSelectingAdditionalCalendars()
                {
                    var observer = Substitute.For <IObserver <bool> >();

                    ViewModel.DoneAction.Enabled.Subscribe(observer);
                    var selectedableUserCalendars = Enumerable
                                                    .Range(0, 10)
                                                    .Select(id =>
                    {
                        var userCalendar = new UserCalendar(id.ToString(), id.ToString(), "Doenst matter");
                        return(new SelectableUserCalendarViewModel(userCalendar, false));
                    });

                    selectedableUserCalendars
                    .ForEach(calendar => ViewModel.SelectCalendarAction.Execute(calendar).Wait());
                    SchedulerProvider.TestScheduler.AdvanceBy(2);

                    Received.InOrder(() =>
                    {
                        observer.OnNext(false);
                        observer.OnNext(true);
                    });
                }
            public async Task ReturnsSuggestionsFromEventsOneHourInThePastAndOneHourInTheFuture()
            {
                var now = new DateTimeOffset(2020, 1, 2, 3, 4, 5, TimeSpan.Zero);

                TimeService.CurrentDateTime.Returns(now);
                var tenMinutes = TimeSpan.FromMinutes(10);
                var events     = Enumerable.Range(1, 5)
                                 .Select(id => new CalendarItem(
                                             id.ToString(),
                                             CalendarItemSource.Calendar,
                                             now - tenMinutes * id,
                                             tenMinutes,
                                             id.ToString(),
                                             CalendarIconKind.None));

                CalendarService
                .GetEventsInRange(Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>())
                .Returns(Observable.Return(events));

                var userCalendar = new UserCalendar(
                    "",
                    "",
                    "",
                    true);

                InteractorFactory.GetUserCalendars().Execute()
                .Returns(Observable.Return(new List <UserCalendar> {
                    userCalendar
                }));

                var suggestions = await Provider.GetSuggestions().ToList();

                await CalendarService.Received().GetEventsInRange(now.AddHours(-1), now.AddHours(1));

                suggestions.Should().HaveCount(1)
                .And.OnlyContain(suggestion => events.Any(@event => @event.Description == suggestion.Description));
            }
            public async Task ReturnsSuggestionsForTheDefaultWorkspace()
            {
                var defaultWorkspace = new MockWorkspace(10);
                var now = new DateTimeOffset(2020, 10, 9, 8, 7, 6, TimeSpan.Zero);

                InteractorFactory.GetDefaultWorkspace().Execute().Returns(Observable.Return(defaultWorkspace));
                TimeService.CurrentDateTime.Returns(now);
                var tenMinutes = TimeSpan.FromMinutes(10);
                var events     = Enumerable.Range(1, 5)
                                 .Select(id => new CalendarItem(
                                             id.ToString(),
                                             CalendarItemSource.Calendar,
                                             now - tenMinutes * id,
                                             tenMinutes,
                                             id.ToString(),
                                             CalendarIconKind.None));

                CalendarService
                .GetEventsInRange(Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>())
                .Returns(Observable.Return(events));

                var userCalendar = new UserCalendar(
                    "",
                    "",
                    "",
                    true);

                InteractorFactory.GetUserCalendars().Execute()
                .Returns(Observable.Return(new List <UserCalendar> {
                    userCalendar
                }));

                var suggestions = await Provider.GetSuggestions().ToList();

                suggestions.Should().OnlyContain(suggestion => suggestion.WorkspaceId == defaultWorkspace.Id);
            }
Пример #29
0
    private void BindUsers()
    {
        if (IsActivating)
        {
            IUser loggedOnUser = ((SLXUserService)(ApplicationContext.Current.Services.Get <IUserService>())).GetUser();
            UserList.Items.Add(new ListItem(loggedOnUser.ToString(), loggedOnUser.Id.ToString()));

            IList <IUser> results       = UserCalendar.GetCalendarUsers(loggedOnUser.Id.ToString());
            int           selectedindex = 0;
            int           i             = 1;
            if (results != null)
            {
                foreach (IUser listUser in results)
                {
                    if (!loggedOnUser.Equals(listUser))
                    {
                        UserList.Items.Add(new ListItem(listUser.ToString(), listUser.Id.ToString()));
                    }
                    i++;
                }
            }
            UserList.SelectedIndex = selectedindex;
        }
    }
Пример #30
0
                public void EmitsFalseAfterAllTheCalendarsHaveBeenDeselected()
                {
                    var observer = Substitute.For <IObserver <bool> >();

                    ViewModel.Done.Enabled.Subscribe(observer);
                    var selectedableUserCalendars = Enumerable
                                                    .Range(0, 10)
                                                    .Select(id =>
                    {
                        var userCalendar = new UserCalendar(id.ToString(), id.ToString(), "Doenst matter");
                        return(new SelectableUserCalendarViewModel(userCalendar, false));
                    });

                    var selectAll = Observable
                                    .Concat(
                        selectedableUserCalendars
                        .Select(calendar => Observable.Defer(() => ViewModel.SelectCalendar.Execute(calendar)))
                        );

                    var auxObserver = TestScheduler.CreateObserver <Unit>();

                    Observable
                    .Concat(
                        selectAll,
                        selectAll
                        )
                    .Subscribe(auxObserver);
                    TestScheduler.Start();

                    Received.InOrder(() =>
                    {
                        observer.OnNext(false);
                        observer.OnNext(true);
                        observer.OnNext(false);
                    });
                }