Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Suggestion([FromBody] AuthorizedUser authorizedUser)
        {
            this.authenticateUser(authorizedUser);
            UserAccount retrievedUser = await authorizedUser.getUserAccount(db).ConfigureAwait(false);

            await retrievedUser.Login().ConfigureAwait(false);

            TilerUser tilerUser = retrievedUser.getTilerUser();

            tilerUser.updateTimeZoneTimeSpan(authorizedUser.getTimeSpan);
            if (retrievedUser.Status)
            {
                DateTimeOffset nowTime = authorizedUser.getRefNow();
                if (retrievedUser.ScheduleLogControl.Now == null)
                {
                    var         retrievalOption = DataRetrievalSet.analysisManipulation;
                    DB_Schedule schedule        = new DB_Schedule(retrievedUser, nowTime, authorizedUser.getCurrentLocation(), retrievalOptions: retrievalOption);
                    retrievedUser.ScheduleLogControl.Now = schedule.Now;
                }

                await SuggestionAnalysis(retrievedUser.ScheduleLogControl, authorizedUser.getCurrentLocation()).ConfigureAwait(false);
            }

            var retValue = new PostBackData("", 0);

            return(Ok(retValue.getPostBack));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> SetAsNow([FromBody] WhatIfModel SetAsNowData)
        {
            AuthorizedUser myAuthorizedUser = SetAsNowData.User;
            UserAccount    retrievedUser    = await SetAsNowData.getUserAccount(db);

            await retrievedUser.Login();

            retrievedUser.getTilerUser().updateTimeZoneTimeSpan(SetAsNowData.getTimeSpan);
            PostBackData returnPostBack;

            if (retrievedUser.Status)
            {
                Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db);
                var retrievalOption = DataRetrievalSet.scheduleManipulation;
                retrievalOption.Add(DataRetrivalOption.TimeLineHistory);
                DB_Schedule schedule       = new DB_Schedule(retrievedUser, myAuthorizedUser.getRefNow(), SetAsNowData.getCurrentLocation(), retrievalOptions: retrievalOption);
                var         thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false);

                schedule.updateDataSetWithThirdPartyData(thirdPartyData);
                schedule.CurrentLocation = myAuthorizedUser.getCurrentLocation();

                var evaluation = await schedule.TimeStone.WhatIfSetAsNow(SetAsNowData.EventId);

                JObject before     = evaluation.Item1.ToJson();
                JObject after      = evaluation.Item2.ToJson();
                JObject resultData = new JObject();
                resultData.Add("before", before);
                resultData.Add("after", after);
                returnPostBack = new PostBackData(resultData, 0);
                return(Ok(returnPostBack.getPostBack));
            }
            else
            {
                returnPostBack = new PostBackData("", 1);
            }

            return(Ok(returnPostBack.getPostBack));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> pushed([FromBody] WhatIfModel UserData)
        {
            AuthorizedUser myAuthorizedUser = UserData.User;
            UserAccount    retrievedUser    = await UserData.getUserAccount(db);

            await retrievedUser.Login();

            retrievedUser.getTilerUser().updateTimeZoneTimeSpan(UserData.getTimeSpan);
            PostBackData returnPostBack;

            if (retrievedUser.Status)
            {
                Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db);
                DB_Schedule schedule       = new DB_Schedule(retrievedUser, myAuthorizedUser.getRefNow(), myAuthorizedUser.getCurrentLocation());
                var         thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false);

                schedule.updateDataSetWithThirdPartyData(thirdPartyData);
                schedule.CurrentLocation = myAuthorizedUser.getCurrentLocation();
                Tuple <Health, Health> evaluation;
                evaluation = await schedule.TimeStone.PushedAll(UserData.Duration, null);

                JObject before     = evaluation.Item1.ToJson();
                JObject after      = evaluation.Item2.ToJson();
                JObject resultData = new JObject();
                resultData.Add("before", before);
                resultData.Add("after", after);
                returnPostBack = new PostBackData(resultData, 0);
                return(Ok(returnPostBack.getPostBack));
            }
            else
            {
                returnPostBack = new PostBackData("", 1);
            }

            return(Ok(returnPostBack.getPostBack));
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> pushedEvent([FromBody] WhatIfModel UserData)
        {
            AuthorizedUser myAuthorizedUser = UserData.User;
            UserAccount    retrievedUser    = await UserData.getUserAccount(db);

            await retrievedUser.Login();

            retrievedUser.getTilerUser().updateTimeZoneTimeSpan(UserData.getTimeSpan);
            PostBackData returnPostBack;

            if (retrievedUser.Status)
            {
                Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db);
                DB_Schedule schedule       = new DB_Schedule(retrievedUser, myAuthorizedUser.getRefNow(), UserData.getCurrentLocation());
                var         thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false);

                schedule.updateDataSetWithThirdPartyData(thirdPartyData);
                schedule.CurrentLocation = myAuthorizedUser.getCurrentLocation();
                Tuple <Health, Health> evaluation;

                SubCalendarEvent subEvent = null;
                try
                {
                    if (String.IsNullOrEmpty(UserData.EventId))
                    {
                        var calEventAndSubEvent = schedule.getNearestEventToNow();
                        subEvent = calEventAndSubEvent.Item2;
                        EventID eventId = new EventID(calEventAndSubEvent.Item2.getId);
                        evaluation = await schedule.TimeStone.PushSingleEvent(UserData.Duration, eventId, null);
                    }
                    else
                    {
                        evaluation = await schedule.TimeStone.PushSingleEvent(UserData.Duration, new EventID(UserData.EventId), null);
                    }

                    JObject before     = evaluation.Item1.ToJson();
                    JObject after      = evaluation.Item2.ToJson();
                    JObject resultData = new JObject();
                    if (subEvent != null)
                    {
                        SubCalEvent subcalevent = subEvent.ToSubCalEvent();
                        JObject     jsonSubcal  = JObject.FromObject(subcalevent);
                        resultData.Add("subEvent", jsonSubcal);
                    }

                    resultData.Add("before", before);
                    resultData.Add("after", after);
                    returnPostBack = new PostBackData(resultData, 0);
                    return(Ok(returnPostBack.getPostBack));
                }
                catch (CustomErrors error)
                {
                    returnPostBack = new PostBackData(error);
                    return(Ok(returnPostBack.getPostBack));
                }
            }
            else
            {
                returnPostBack = new PostBackData("", 1);
            }

            return(Ok(returnPostBack.getPostBack));
        }