Пример #1
0
        public ActionResult Start(int deckId = 0)
        {
            if (deckId == 0)
            {
                return(HttpNotFound());
            }
            UserStatistic statistic;

            if (WebSecurity.IsAuthenticated)
            {
                statistic = statisticRepository.GetAll(s => s.UserID == WebSecurity.CurrentUserId && s.DeckID == deckId).FirstOrDefault();
                if (statistic == null)
                {
                    statistic = new UserStatistic()
                    {
                        UserID = WebSecurity.CurrentUserId, DeckID = deckId, LastViewed = DateTime.Now
                    };
                    statisticRepository.Add(statistic);
                }
                else
                {
                    statistic.LastViewed = DateTime.Now;
                    statistic.UnknownCards.Clear();
                    statisticRepository.Update(statistic);
                }
            }
            else
            {
                statistic = new UserStatistic()
                {
                    UserID = -1, DeckID = deckId, LastViewed = DateTime.Now, UnknownCards = new HashSet <Card>()
                };
            }
            Session["statistic"] = statistic;

            return(RedirectToAction("ShowNextCard", new { deckId = deckId }));
        }
Пример #2
0
        /// <summary>
        /// Method for get one UserStatistic object for a specific year for a specific user based on data from HistoryTrip retository.
        /// </summary>
        /// <param name="year">For this year you need to get statistics.</param>
        /// <param name="userId">Statistics for user with userId.</param>
        /// <returns>Return UserStatistic object based on data from HistoryTrip retository.</returns>
        public UserStatistic GetByYear(int year, string userId)
        {
            List <SelectListItem> years = GetAllYears(userId);

            //history clear
            if (years.Count == 0)
            {
                return(GetDefaultUserStatistic(userId));
            }

            var historyTrip = _historyTripService.GetHistoryByYear(year, userId);
            var statistic   = new UserStatistic()
            {
                Year           = year,
                Years          = years,
                ObserveTrips   = _historyTripService.GetDurationTrips(historyTrip),
                CountTrips     = _historyTripService.GetCountTrips(historyTrip),
                LocationsTrips = _historyTripService.GetLocationsTrips(historyTrip),
                LastTrip       = _historyTripService.GetLatsTripByYear(year, userId),
                User           = _repositoryUser.GetById(userId),
            };

            return(statistic);
        }
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#line 3 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
            UserStatistic stat = (UserStatistic)ViewData["statistic"];

#line default
#line hidden
#line 4 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"

            ViewData["Title"] = "ProfileInfo";

#line default
#line hidden
            BeginContext(160, 48, true);
            WriteLiteral("\r\n<h1>Profile:</h1>\r\n<div class=\"oneline\">\r\n    ");
            EndContext();
            BeginContext(208, 790, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "60a1ec80d8a3c00e69b3096b6273aa9a9abb77c54617", async() => {
                BeginContext(257, 105, true);
                WriteLiteral("\r\n        <div class=\"form-group\">\r\n            <input type=\"text\" class=\"form-control elem\" name=\"Email\"");
                EndContext();
                BeginWriteAttribute("value", " value=\"", 362, "\"", 382, 1);
#line 12 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
                WriteAttributeValue("", 370, Model.Email, 370, 12, false);

#line default
#line hidden
                EndWriteAttribute();
                BeginContext(383, 131, true);
                WriteLiteral(" readonly>\r\n        </div>\r\n        <div class=\"form-group\">\r\n            <input type=\"number\" class=\"form-control elem\" name=\"Age\"");
                EndContext();
                BeginWriteAttribute("value", " value=\"", 514, "\"", 532, 1);
#line 15 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
                WriteAttributeValue("", 522, Model.Age, 522, 10, false);

#line default
#line hidden
                EndWriteAttribute();
                BeginContext(533, 144, true);
                WriteLiteral(" placeholder=\"Your Age\">\r\n        </div>\r\n        <div class=\"form-group\">\r\n            <input type=\"text\" class=\"form-control elem\" name=\"City\"");
                EndContext();
                BeginWriteAttribute("value", " value=\"", 677, "\"", 696, 1);
#line 18 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
                WriteAttributeValue("", 685, Model.City, 685, 11, false);

#line default
#line hidden
                EndWriteAttribute();
                BeginContext(697, 147, true);
                WriteLiteral(" placeholder=\"Your City\">\r\n        </div>\r\n        <div class=\"form-group\">\r\n            <input type=\"text\" class=\"form-control elem\" name=\"Street\"");
                EndContext();
                BeginWriteAttribute("value", " value=\"", 844, "\"", 865, 1);
#line 21 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
                WriteAttributeValue("", 852, Model.Street, 852, 13, false);

#line default
#line hidden
                EndWriteAttribute();
                BeginContext(866, 125, true);
                WriteLiteral(" placeholder=\"Your Street\">\r\n        </div>\r\n        <button type=\"submit\" class=\"btn btn-success elem\">Update</button>\r\n    ");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
            __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
            __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_0.Value;
            __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
            __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(998, 85, true);
            WriteLiteral("\r\n</div>\r\n<div class=\"oneline\">\r\n    <div class=\"well stat\">\r\n        Orders made is ");
            EndContext();
            BeginContext(1084, 16, false);
#line 28 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
            Write(stat.CountOrders);

#line default
#line hidden
            EndContext();
            BeginContext(1100, 67, true);
            WriteLiteral("\r\n    </div>\r\n    <div class=\"well stat\">\r\n        Books bought is ");
            EndContext();
            BeginContext(1168, 15, false);
#line 31 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
            Write(stat.CountBooks);

#line default
#line hidden
            EndContext();
            BeginContext(1183, 70, true);
            WriteLiteral("\r\n    </div>\r\n    <div class=\"well stat\">\r\n        Total sum spend is ");
            EndContext();
            BeginContext(1254, 13, false);
#line 34 "C:\Users\misha\University\C#\BookMagazine\BookShop\BookShop\Views\User\ProfileInfo.cshtml"
            Write(stat.TotalSum);

#line default
#line hidden
            EndContext();
            BeginContext(1267, 20, true);
            WriteLiteral("\r\n    </div>\r\n</div>");
            EndContext();
        }
Пример #4
0
        /// <summary>Открытие формы с статистикой о пользователе.</summary>
        private void BtUserStatistic_Click(object sender, EventArgs e)
        {
            var userStat = new UserStatistic();

            userStat.ShowDialog();
        }