Esempio n. 1
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     QuestionListItems.Clear();
     contestID = int.Parse(e.Fragment);
     var list = from id in App.Server.GetQuestionList(contestID)
                let q = App.Server.GetQuestion(id)
                select new QuestionListItem
                {
                    ID = q.ID,
                    AskerID = q.AskerID,
                    Answer = q.Answer,
                    Asker =q.Asker,
                    Contest = q.Contest,
                    ContestID = q.ContestID,
                    ContestName = q.ContestName,
                    Description = q.Description,
                    Status = q.Status,
                    StatusAsInt = q.StatusAsInt,
                    Time = q.Time,
                    AskerNickName = q.AskerNickName
                };
     foreach (var item in list) QuestionListItems.Add(item);
     lstQuestion.ItemsSource = QuestionListItems;
     lstQuestion.Items.Refresh();
 }
Esempio n. 2
0
        public void OnNavigatedFrom(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
        {
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += backgroundWorker_LightsOff;
            //backgroundWorker.RunWorkerAsync();
        }
 public void OnNavigatingFrom(FirstFloor.ModernUI.Windows.Navigation.NavigatingCancelEventArgs e)
 {
     if (ModernDialog.ShowMessage("Покинуть режим редактирования данных?\nВсе несохраненные данные будут утеряны.", "навигация", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.No)
     {
         e.Cancel = true;
     }
 }
Esempio n. 4
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     _liveWire.RunWorkerAsync();
     _recentTrasnsactions.Clear();
     _monthlyIncomeVsExpences.Clear();
     _accounts?.Clear();
 }
Esempio n. 5
0
    IEnumerator SleepAniOff()
    {
        //Debug.Log("코루틴");
        SoundManager.instance.PlayEff(EffSound.SFX_UI_sleep);
        bool isOnce = true;

        while (anim.GetCurrentAnimatorStateInfo(0).normalizedTime < 1f)
        {
            //Debug.Log("플레이중");
            if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.9f && isOnce)
            {
                EndDayTime?.Invoke(false);
                isOnce = false;
            }
            yield return(null);
        }

        //Debug.Log("탈출");
        SleepAni.SetActive(false);
        isEndTime = false;
        hour      = 7;
        min       = 0;

        SoundManager.instance.PlayBGM(BGMSound.BGM_inStore);
        SoundManager.instance.PlayEffBgm(BGMEffSound.AMB_Forest);
        FirstFloor.SetActive(true);
        yield return(null);
    }
Esempio n. 6
0
    public static void stairs()
    {
        WriteLine("You enter the small room with the stairs; there's nothing of interest in the room, so you descend the stairs.");
        WriteLine("Press 'Enter' to continue.");
        Console.ReadLine();

        WriteLine("The stairs end at a concrete landing. Through an archway, you see a 2nd smaller room. There are doors to the left, right, and straight ahead. The door ahead is wider and taller, but nothing else really differentiates the doors.");
        WriteLine("What would you like to do?");

        WriteLine("1. Check the Left door\n2. Check the right door\n3. Check the door Ahead\n4. Go Back up the stairs\nAnything Else: Quit the Program.");
        int stairsChoice = Int32.Parse(ReadLine());

        switch (stairsChoice)
        {
        case 1:
            laundryRoom();
            break;

        case 2:
            den();
            break;

        case 3:
            entertainmentRoom();
            break;

        case 4:
            WriteLine("You change your mind and head back up the stairs and re-enter the kitchen.");
            FirstFloor.kitchen();               // have to check this
            break;

        default:
            break;
        }
    }
Esempio n. 7
0
        private void SecondFloor(object sender, RoutedEventArgs e)
        {
            FirstFloor psprat = new FirstFloor();

            psprat.Show();
            this.Close();
        }
Esempio n. 8
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     //find test cases
     string[] files = System.IO.Directory.GetFiles(Static.SourceFileDirectory, "*.in");
     int i = 0;
     Static.TestCases = new List<TestCase>();
     Static.TestCases.Clear();
     foreach (string file in files)
     {
         if (System.IO.Path.GetFileName(file).ToLower() == "spj.exe")
         {
             txtSpecialJudge.Text = file;
         }
         if (System.IO.File.Exists(System.IO.Path.GetDirectoryName(file) + "\\" + System.IO.Path.GetFileNameWithoutExtension(file) + ".ans"))
         {
             TestCase t = new TestCase();
             t.Index = i++;
             t.Input = file;
             t.Output = System.IO.Path.GetDirectoryName(file) + "\\" + System.IO.Path.GetFileNameWithoutExtension(file) + ".ans";
             Static.TestCases.Add(t);
         }
         else if (System.IO.File.Exists(System.IO.Path.GetDirectoryName(file) + "\\" + System.IO.Path.GetFileNameWithoutExtension(file) + ".out"))
         {
             TestCase t = new TestCase();
             t.Index = i++;
             t.Input = file;
             t.Output = System.IO.Path.GetDirectoryName(file) + "\\" + System.IO.Path.GetFileNameWithoutExtension(file) + ".out";
             Static.TestCases.Add(t);
         }
     }
     TestCasesListBox.ItemsSource = Static.TestCases;
 }
Esempio n. 9
0
 public void handSurvived()
 {
     Console.WriteLine("The hand reaches for you... but you manage to dodge to one side. It passes through the wall of the hallway, and disappears. You hear a short but low chuckle from... somewhere. You decide to continue with the hall... ");
     Console.WriteLine("Press 'Enter' to continue.");
     Console.ReadLine();
     FirstFloor.hall();
     // test this decision
 }
Esempio n. 10
0
        private void FirstFloor(object sender, RoutedEventArgs e)

        {
            FirstFloor firstf = new FirstFloor();

            firstf.Show();
            this.Close();
        }
Esempio n. 11
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     var record_id = int.Parse(e.Fragment);
     var record = App.Server.GetRecord(record_id);
     contest_id = App.Server.GetProblemRelatedContest(record.ProblemID);
     txtSource.Document.Blocks.Clear();
     txtSource.Document.Blocks.Add(new Paragraph(new Run(record.Code)));
 }
Esempio n. 12
0
 public void OnNavigatingFrom(FirstFloor.ModernUI.Windows.Navigation.NavigatingCancelEventArgs e)
 {
     if (isLeavePageAllowed == false || e.Source.OriginalString != "/Pages/Home.xaml")
     {
         e.Cancel = true;
         return;
     }
 }
Esempio n. 13
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(_assetWatchedType))
     {
         _assetWatchedType = e.Fragment;
         generateContents();
     }
 }
Esempio n. 14
0
    public void handPassedThrough()
    {
        Console.WriteLine("The hand reaches for your chest... and passes through it. There were no physical effects but you are pretty shaken up. You hear, in the distance, a low, ominous chuckle. You continue on.");
        Console.WriteLine("Press 'Enter' to continue.");
        Console.ReadLine();
        var hallReturn = new FirstFloor();

        FirstFloor.hall();
    }
 /// <summary>
 /// Called when navigation to a content fragment begins.
 /// </summary>
 /// <param name="e">An object that contains the navigation data.</param>
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     this.InitializeUrlParameters(e);
     if (isInitialized)
     {
         this.ShowProgressBar();
         this.InitializeInternal();
     }         
 }
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     
     string id = e.Fragment;
     Market market = Market.getInstance();
     _order = market.Orders.Find(i => i.Id == id);
     show(_order);
     
 }
Esempio n. 17
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     contest = App.Server.GetContest(int.Parse(e.Fragment));
     contest_id = contest.ID;
     RebuildColumn(contest_id);
     StandingItems = Bll.StandingsCache.Standings[contest_id] as List<Entity.StandingItem>;
     Sort();
     dgStandings.ItemsSource = StandingItems;
     dgStandings.Items.Refresh();
 }
        public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
        {

            var tcc = VisualHelper.FindChild<TransitioningContentControl>(this, null);
            if (tcc != null)
            {
                tcc.Transition = "ModernUITransition";
            }

            var currentBusinessProcessSourceType = e.Fragment;
            (this.DataContext as MainContentViewModel).NavigateTo(currentBusinessProcessSourceType); 
        }
Esempio n. 19
0
        public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(e.Fragment))
            {
                var uri = new Uri("http://localhost/?" + e.Fragment);
                var query = System.Web.HttpUtility.ParseQueryString(uri.Query);

                txtImageID.Text = query.Get("ImageId");
                ViewData.ImageId = Int32.Parse(txtImageID.Text);
                GetImageCommand.Execute(null, btnFetch);
            }
        }
Esempio n. 20
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(e.Fragment))
     {
         var pair = e.Fragment.Split('=');
         var temp = pair[1];
         int memberId = 0;
         Int32.TryParse(temp, out memberId);
         ViewData.MemberId = memberId;
         GetMemberCommand.Execute(null, btnFetch);
     }
 }
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     FragmentManager fm = new FragmentManager(e.Fragment);
     string currentExecutionResultId = fm.Fragments["executionResultRunId"];
     ExecutionResultRun executionResultRun = ATACore.Managers.ExecutionResultRunManager.GetByExecutionResultRun(ATACore.Managers.ContextManager.Context, currentExecutionResultId);
     List<TestResultRun> testResultRuns = ATACore.Managers.TestResultRunManager.GetRunsByExecutionResultRun(ATACore.Managers.ContextManager.Context, currentExecutionResultId);
     CurrentExecutionResultsViewModel = new AutomationTestAssistantDesktopApp.CurrentExecutionResultsViewModel(executionResultRun, testResultRuns);
     ATACore.Managers.ContextManager.Dispose();
     mainGrid.DataContext = CurrentExecutionResultsViewModel;
     executionResultRunGrid.DataContext = CurrentExecutionResultsViewModel.ExecutionResultRunViewModel;
     testResultRunDataGrid.ItemsSource = CurrentExecutionResultsViewModel.ObservableTestResultRunViewModels;
 }
Esempio n. 22
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     Company company = NavigationService.GetParameter<Company>(e);
     CompanyEditViewModel vm = (CompanyEditViewModel) this.DataContext;
     if (company != null)
     {
         vm.ShowCompany(company);
     }
     else
     {
         vm.ShowCompany();
     }
 }
Esempio n. 23
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     Reservation reservation = NavigationService.GetParameter<Reservation>(e);
     ReservationEditViewModel vm = (ReservationEditViewModel) this.DataContext;
     if (reservation != null)
     {
         vm.ShowReservation(reservation);
     }
     else
     {
         vm.ShowReservation();
     }
 }
Esempio n. 24
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     Contract contract = NavigationService.GetParameter<Contract>(e);
     ContractEditViewModel vm = (ContractEditViewModel) this.DataContext;
     if (contract != null)
     {
         vm.ShowContract(contract);
     }
     else
     {
         vm.ShowContract();
     }
 }
        private void menu_SelectedSourceChanged(object sender, FirstFloor.ModernUI.Windows.Controls.SourceEventArgs e)
        {
            if (loader == null)
                return;

            if (e.Source.ToString().Trim().Contains(loader.LastLoad?.ToString().Trim()))
            {
                BookListTransition tr = new BookListTransition();
                //loader.Transition.move(tr);
                tr.loadAsync(loader.Transition);

            }
        }
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     if (e.Fragment != "")
     {
         DatabaseInfo dbInfo = library.RetrieveDatabaseNode(e.Fragment);
         if (dbInfo == null)
         {
             FirstFloor.ModernUI.Windows.Controls.ModernDialog.ShowMessage("The database requested was not found!", "Not Found", MessageBoxButton.OK);
             NavigationCommands.GoToPage.Execute(new Uri("/Pages/DatabasesPage.xaml", UriKind.Relative), FirstFloor.ModernUI.Windows.Navigation.NavigationHelper.FindFrame(null, this));
         }
         CurrentDbInfo = dbInfo;
         CurrentDatabaseName = dbInfo.DatabaseName;
         CurrentStartTime = dbInfo.StartTime.ToString();
     }
 }
Esempio n. 27
0
 /// <summary>
 /// Определяет график, необходимый к отображению
 /// </summary>
 /// <param name="e">An object that contains the navigation data.</param>
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     try
     {
         graphicType = (GraphicType)int.Parse(e.Fragment);
         if (graphicType == GraphicType.Followers)
             PrintGraphicFollowers();
         else if (graphicType == GraphicType.Following)
             PrintGraphicFollowing();
         else PrintGraphicMedia();
     }
     catch(Exception exc)
     {
        Client.Pages.MainPage.ShowMessage(ApiServer.ErrorMessageForClient);
     }
 }
 void IContent.OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     if (Data.MovieId != -1)
     {
         if (first)
         {
             this.DataContext = new MovieDetailsViewModel(Data.MovieId);
             first = false;
         }
         else if (Data.MovieId != MovieDetailsViewModel.CurrentId)
             ((MovieDetailsViewModel)this.DataContext).SetNewMovie(Data.MovieId);
     }
     else
     {
         ((ModernWindow)Application.Current.MainWindow).ContentSource = new Uri("/Views/Home.xaml", UriKind.Relative);
         ModernDialog.ShowMessage("Please select a movie first!", "No movie selected!", MessageBoxButton.OK);
     }
 }
Esempio n. 29
0
        public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
        {
            var match = Regex.Match(e.Fragment, @"^field=(.*?)&id=(\d*)$");
            field = match.Groups[1].Value;
            id = int.Parse(match.Groups[2].Value);

            var problem = App.Server.GetProblem(id);

            string value;
            switch (field)
            {
                case "Spj":
                    value = problem.Spj == null ? "" : problem.Spj;
                    break;
                case "Std":
                    value = problem.Std == null ? "" : problem.Std;
                    break;
                case "Validator":
                    value = problem.Validator == null ? "" : problem.Validator;
                    break;
                default:
                    throw new ArgumentException("field");
            }

            ProgrammingLanguage language;
            switch (field)
            {
                case "Spj":
                    language = problem.SpjLanguage == null ? ProgrammingLanguage.C : problem.SpjLanguage.Value;
                    break;
                case "Std":
                    language = problem.StdLanguage == null ? ProgrammingLanguage.C : problem.StdLanguage.Value;
                    break;
                case "Validator":
                    language = problem.ValidatorLanguage == null ? ProgrammingLanguage.C : problem.ValidatorLanguage.Value;
                    break;
                default:
                    throw new ArgumentException("field");
            }

            txtCode.Document.Blocks.Clear();
            txtCode.Document.Blocks.Add(new Paragraph(new Run(value)));
            cbLanguage.SelectedIndex = (int)language;
        }
Esempio n. 30
0
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     if (e.Source.ToString().Contains("from_title_links=1"))
     {
         if (Nijie.IsLoggedIn)
         {
             var result = ModernDialog.ShowMessage("Logout?", "Confimation", MessageBoxButton.YesNo);
             if (result == MessageBoxResult.Yes)
             {
                 MainWindow.Bot.Logout();
                 lblLoginStatus.Text = "Logged Out.";
             }
         }
     }
     else if (e.Source.ToString().Contains("autologin"))
     {
         isAutoLogin = true;
     }
 }
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     if (e.NavigationType == FirstFloor.ModernUI.Windows.Navigation.NavigationType.New)
     {
         var menuCollection = (App.Current.MainWindow as ModernWindow).MenuLinkGroups.First((x) => { return x.GroupName == "MetaDataGroup"; });
         if (menuCollection != null && menuCollection.Links.Count > 0)
         {
             menuCollection.Links.Clear();
         }              
         var mf = VisualHelper.FindChild<ModernFrame>(App.Current.MainWindow, "ContentFrame");
         if (mf != null)
         {
             while (NavigationCommands.BrowseBack.CanExecute(null, mf))
             {
                 NavigationCommands.BrowseBack.Execute(null, mf);
             }
         }
     }
 }
Esempio n. 32
0
 public static void kitchenSearch(int choice)
 {
     Console.Clear();
     switch (choice)
     {
         case 1:
             //oven
             WriteLine("You go to the oven. it's a standard gas stovetop-gas oven. You open the oven door and see... writing? ");
             WriteLine("In a red marker or paint, on the back wall, is a message:");
             WriteLine("She is cursed!");
             WriteLine("You don't know who 'she' is. You shut the oven door.");
             FirstFloor.kitchen();
             break;
         case 2:
             WriteLine("You walk up to the spot on the wall where the green glow is coming from. There's no heat or cold in the area, just the glow. You push on the wall but nothing happens.");
             WriteLine("You then notice a discolored spot on wall, a few feet to the left. You press on it, and a section of the wall swings open, revealing the green glow....");
             WriteLine("Multiple arms shoot from the glow! They grab onto your arms, you hair, anywhere that they can find a grip! You are yanked into the green light... and land in the front yard of another house. As you sit up, the front door of this house opens up and 3 figures - 2 women and a man - rush out to meet you.");
             WriteLine("'Thank goodness we snagged you in time!', one of the women exclaim. 'You are not prepared to take on what's in that house - come with us!', the man states. You follow them into the house, where you fate is put on hold until Part II....");
             break;
         case 3:
             //yellow glow - GOOD
             WriteLine("You walk up to the spot on the wall where the yellow glow is coming from. You don't see any kind of opening but you do see a small, slightly discolored spot on the wall, a few feet away. You push it and a stone slab slides down into an until-then unseen groove. Inside the opening is what appears to be a small altar or shrine. There are dozens of small, lit candles - the source of the yellow light. There is a medium-sized silver cross on top of a two-tiered table. There are smaller crosses on either end of the lower tier, set into bases. On the top tier is... a box of bullets?");
             WriteLine("You open the box and see 12 long, silver bullets. This is not a coincidence, you think to your self. You also realize that silver bullets need some kind of Gun to go with them... and possibly some target to use them on.");
             WriteLine("You take the box of bullets and leave the shrine, heading back into the kitchen.");
             WriteLine("Press 'Enter' to continue.");
             Console.ReadLine();
             FirstFloor.kitchen();
             break;
         case 4:
             Basement.stairs();
             break;
         case 5:
             WriteLine("You find some odds and ends: a couple of take-out menus, a few receipts, a newspaper. You don't see anything else of importance.");
             FirstFloor.kitchen();
             break;
         case 6:
             WriteLine("You leave the Kitchen and head back into the main Hall.");
             FirstFloor.hall();
             break;
         default:
             break;
     }
 } 
 public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
 {
     helpList.Links.Clear();
     string filePath = "Debugger.QuickGuide.QG.xml";
     string code = QuickGuide.GetResourceTextFile(filePath, this);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(code);
     XmlElement root = doc.DocumentElement;
     int node = 0;
     foreach (XmlElement elem in root.ChildNodes)
     {
         helpList.Links.Add(new Link
         {
             DisplayName = elem.Attributes["name"].Value,
             Source = new Uri(string.Format("QuickGuide/QuickGuide.xaml#QG:{0}", node), UriKind.Relative)
         });
         ++node;
     }
     helpList.SelectedSource = helpList.Links[0].Source;
 }
Esempio n. 34
0
        public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
        {
            if (Session.Instance.Price == 0)
                return;
            Ticket.Text = Session.Instance.Ticket; 
            float price = ((float)Session.Instance.Price) / 100;
            TotalPrice.Text = String.Format("Price: {0:0.00} €", price);
            TotalPaid.Text = String.Format("Total paid: {0:0.00} €", 0);
            Remaining.Text = String.Format("Remaining: {0:0.00} €", price);

            CashChanger cashChanger = Session.Instance.CashChanger;
            try
            {
                cashChanger.DataEvent += OnDataEvent;
                cashChanger.DataEventEnabled = true;
                cashChanger.BeginDeposit();
            }
            catch (Exception)
            {
                MessageBox.Show("Cash Unit out of order");
            }
        }
Esempio n. 35
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     contest_id = int.Parse(e.Fragment);
     var ids = App.Server.GetHackList(contest_id);
     HackListBoxItems.Clear();
     foreach (var hid in ids)
     {
         var hack = App.Server.GetHackGeneral(hid);
         var item = new HackListBoxItem()
         {
             ProblemTitle = hack.ProblemTitle,
             HackerUserNickName = hack.HackerUserNickName,
             DefenderUserNickName = hack.DefenderUserNickName,
             HackID = hack.HackID,
             RecordID = hack.RecordID,
             Status = hack.Status,
             Time = hack.Time
         };
         HackListBoxItems.Add(item);
     }
     lstHack.Items.Refresh();
 }
Esempio n. 36
0
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     record_id = int.Parse(e.Fragment);
     record = App.Server.GetRecord(record_id);
     txtSource.Document.Blocks.Clear();
     txtSource.Document.Blocks.Add(new Paragraph(new Run(record.Code)));
     var p = App.Server.GetProblem(record.ProblemID);
     var languages = Enum.GetNames(typeof(Entity.ProgrammingLanguage));
     cbbLanguage.Items.Clear();
     foreach (var l in languages)
     {
         cbbLanguage.Items.Add(l);
     }
     var forbidden = p.ForbiddenLanguages.ToList();
     foreach (var l in forbidden)
     {
         var index = cbbLanguage.Items.IndexOf(l);
         if (index >= 0)
             cbbLanguage.Items.RemoveAt(index);
     }
     cbbLanguage.Items.Refresh();
     cbbLanguage.SelectedIndex = 0;
 }
Esempio n. 37
0
 public void OnNavigatingFrom(FirstFloor.ModernUI.Windows.Navigation.NavigatingCancelEventArgs e)
 {
 }
Esempio n. 38
0
        public ActionResult RequestAudit(PlanToApprove planRequestToApprove)
        {
            NullChecker.NullCheck(new object[] { planRequestToApprove.req });

            if (ModelState.IsValid)
            {
                var planToApprove = unitOfWork.PlanRequetRepository
                                    .GetByID(EncryptionHelper.Unprotect(planRequestToApprove.req));
                if (planToApprove.payment == null)
                {
                    return(new RedirectToNotFound());
                }

                if (planRequestToApprove.approve && planRequestToApprove.plantype == PlanType.Company)
                {
                    if (planToApprove is RequestForNew)
                    {
                        var New = planToApprove as RequestForNew;

                        CompanyNotExpired newCompany = new CompanyNotExpired();
                        if (planToApprove.plan == "Imperial")
                        {
                            newCompany = new Imperial();
                        }
                        else if (planToApprove.plan == "Luxury")
                        {
                            newCompany = new Luxury();
                        }
                        else if (planToApprove.plan == "HighClass")
                        {
                            newCompany = new HighClass();
                        }
                        else
                        {
                            return(RedirectToAction("AllRequests"));
                        }

                        planToApprove.payment.payAcceptDate = DateTime.UtcNow;

                        newCompany.regCode       = (long)New.regCode;
                        newCompany.coName        = New.name;
                        newCompany.coNameEN      = New.name;
                        newCompany.about         = New.about;
                        newCompany.aboutEN       = New.about;
                        newCompany.address       = New.address;
                        newCompany.addressEN     = New.address;
                        newCompany.email         = New.Email;
                        newCompany.phoneNo       = (long)New.phoneNo;
                        newCompany.stateID       = New.stateID;
                        newCompany.InsertionDate = DateTime.UtcNow;
                        newCompany.registerDate  = DateTime.UtcNow;

                        newCompany.Admins = new List <ActiveUser>();
                        newCompany.Admins.Add(planToApprove.requesterUser);

                        newCompany.Followers = new List <Following>();
                        newCompany.Followers.Add(new Following
                        {
                            FollowerUser = planToApprove.requesterUser,
                            followDate   = DateTime.UtcNow
                        });


                        Setting newSetting = new Setting();
                        newCompany.Setting = newSetting;

                        unitOfWork.NotExpiredCompanyRepository.Insert(newCompany);
                        planToApprove.approve = true;

                        unitOfWork.Save();



                        if (!Roles.IsUserInRole(planToApprove.requesterUser.UserName, "CoAdmin"))
                        {
                            Roles.AddUserToRole(planToApprove.requesterUser.UserName, "CoAdmin");
                        }


                        return(RedirectToAction("AllRequests"));
                    }
                    else if (planToApprove is RevivalRequest)
                    {
                        var New = planToApprove as RevivalRequest;
                        New.approve = true;
                        DateTime lastPayement = unitOfWork.RevivalPlanRequestRepository.Get(r => r.coID == New.coID).Max(c => c.payment.payDate);
                        New.payment.payDate = lastPayement.AddDays(365);
                        unitOfWork.RevivalPlanRequestRepository.Update(New);
                        unitOfWork.CompanyPlanChange((int)New.coID, New.plan);
                        unitOfWork.Save();
                        return(RedirectToAction("AllRequests"));
                    }
                    return(new RedirectToError());
                }
                else if (planRequestToApprove.approve && planRequestToApprove.plantype == PlanType.Store)
                {
                    if (planToApprove is RequestForNew)
                    {
                        var             New      = planToApprove as RequestForNew;
                        StoreNotExpired newStore = new StoreNotExpired();
                        if (planToApprove.plan == "GroundFloor")
                        {
                            newStore = new GroundFloor();
                        }
                        else if (planToApprove.plan == "FirstFloor")
                        {
                            newStore = new FirstFloor();
                        }
                        else if (planToApprove.plan == "SecondFloor")
                        {
                            newStore = new SecondFloor();
                        }
                        else
                        {
                            return(RedirectToAction("AllRequests"));
                        }

                        planToApprove.payment.payAcceptDate = DateTime.UtcNow;

                        newStore.regCode      = New.regCode;
                        newStore.storeName    = New.name;
                        newStore.storeNameEN  = New.name;
                        newStore.about        = New.about;
                        newStore.aboutEN      = New.about;
                        newStore.address      = New.address;
                        newStore.addressEN    = New.address;
                        newStore.email        = New.Email;
                        newStore.phoneNo      = (long)New.phoneNo;
                        newStore.stateID      = New.stateID;
                        newStore.registerDate = DateTime.Now.ToLocalTime();

                        newStore.Admins = new List <ActiveUser>();
                        newStore.Admins.Add(planToApprove.requesterUser);

                        newStore.Followers = new List <Following>();
                        newStore.Followers.Add(new Following
                        {
                            FollowerUser = planToApprove.requesterUser,
                            followDate   = DateTime.UtcNow
                        });

                        Setting newSetting = new Setting();
                        newStore.Setting = newSetting;

                        unitOfWork.StoreNotExpiredRepository.Insert(newStore);
                        planToApprove.approve = true;
                        unitOfWork.Save();



                        if (!Roles.IsUserInRole(planToApprove.requesterUser.UserName, "StAdmin"))
                        {
                            Roles.AddUserToRole(planToApprove.requesterUser.UserName, "StAdmin");
                        }

                        return(RedirectToAction("AllRequests"));
                    }
                    else if (planToApprove is RevivalRequest)
                    {
                        var New = planToApprove as RevivalRequest;
                        New.approve = true;
                        DateTime lastPayement = unitOfWork.RevivalPlanRequestRepository.Get(r => r.storeID == New.storeID).Max(c => c.payment.payDate);
                        New.payment.payDate = lastPayement.AddDays(365);
                        unitOfWork.RevivalPlanRequestRepository.Update(New);
                        unitOfWork.StorePlanChange((int)New.storeID, New.plan);
                        unitOfWork.Save();
                        return(RedirectToAction("AllRequests"));
                    }
                    return(new RedirectToError());
                }
                else if (planRequestToApprove.approve && planRequestToApprove.plantype == PlanType.User)
                {
                    if (planToApprove is RevivalRequest)
                    {
                        var New = planToApprove as RevivalRequest;

                        UserProfile newUser = new UserProfile();
                        if (planToApprove.plan.ToLower() == "Professional")
                        {
                            newUser = new Professional();
                        }
                        else if (planToApprove.plan.ToLower() == "Premium")
                        {
                            newUser = new Premium();
                        }
                        else if (planToApprove.plan.ToLower() == "Basic")
                        {
                            newUser = new Basic();
                        }
                        else
                        {
                            return(RedirectToAction("AllRequests"));
                        }

                        New.approve = true;
                        DateTime lastPayement = unitOfWork.RevivalPlanRequestRepository.Get(r => r.userID == New.userID).Max(c => c.payment.payDate);
                        New.payment.payDate = lastPayement.AddDays(365);
                        unitOfWork.RevivalPlanRequestRepository.Update(New);
                        unitOfWork.UserPlanChange((int)New.userID, New.plan);
                        planToApprove.approve = true;
                        unitOfWork.Save();
                        return(RedirectToAction("AllRequests"));
                    }
                    else
                    {
                        return(new RedirectToError());
                    }
                }
            }
            return(new RedirectToError());
        }