public async Task CreateSummaryJson()
        {
            _loggerService.Log("Start processing the summary json request");
            _loggerService.Log("Send a request to another service to count the words");
            var contentTest = JsonSerializer.Serialize(_stringList);
            var content     = new StringContent(contentTest, Encoding.UTF8, "application/json");
            var response    = await client.PostAsync(_configProvider.CounterApiUrl, content);

            var responseString = await response.Content.ReadAsStringAsync();

            _loggerService.Log("Got the response from the service!");

            int        wordSum = Int32.Parse(responseString);
            SummaryDto summary = new SummaryDto()
            {
                Id            = _id,
                NumberOfWords = wordSum,
                Source        = _source
            };
            string summaryJson = JsonSerializer.Serialize(summary);

            _loggerService.Log("Creating the summary json...");
            _helperIO.CreateJson(_path, summaryJson, _newDirectoryName.ToString(), _skinyGuid, false);
            _loggerService.Log("Summary json created");
        }
Example #2
0
        public SummaryDto CreateForUser(Int32 userId, CreateSummaryDto summaryData)
        {
            User user = _userRepository.Get(userId);

            if (user.Type != UserType.Candidate)
            {
                throw new ArgumentException($"Unable to create summary for not candidate user with id {userId}!");
            }

            if (_summaryRepository.IsHaveForUser(userId))
            {
                throw new ArgumentException($"Summary for user with id {userId} have already created!");
            }

            var summary = new Summary(
                user,
                _specializationRepository.GetByName(summaryData.Specialization),
                summaryData.Skills
                .Select(s => _skillRepository.GetByName(s))
                .ToList(),
                summaryData.Information);

            summary = _summaryRepository.Create(summary);

            return(SummaryDto.Create(summary));
        }
Example #3
0
        public void Should_create_new_summary_for_user_in_repository()
        {
            // Arrange
            var userId      = 4;
            var summaryData = new CreateSummaryDto(
                "Spec2",
                new List <String> {
                "Skill1", "Skill3"
            },
                "Inform");

            var expected = new SummaryDto(
                userId,
                2,
                summaryData.Specialization,
                summaryData.Skills,
                summaryData.Information);

            // Act
            var result = _summaryService.CreateForUser(userId, summaryData);

            // Assert
            Assert.That(result != null);
            Assert.That(result.Equals(expected));
            Assert.That(result.Equals(SummaryDto.Create(_summaryRepository.GetForUser(userId))));
        }
Example #4
0
 public LineTestResultsDto(XElement lineTestResultsElement)
 {
     CompleteDate = lineTestResultsElement.GetElementValue("completeDate");
     CompleteTime = lineTestResultsElement.GetElementValue("completeTime");
     LineCircuit = new LineCircuitDto(lineTestResultsElement.GetElement("LineCircuit"));
     Summary = new SummaryDto(lineTestResultsElement.GetElement("Summary"));
 }
Example #5
0
        public void Should_return_summary_for_user_same_as_from_repository()
        {
            // Arrange
            var userId   = 1;
            var expected = SummaryDto.Create(_summaryRepository.GetForUser(userId));

            // Act
            var result = _summaryService.GetForUser(userId);

            // Assert
            Assert.That(result != null);
            Assert.That(result.Equals(expected));
        }
Example #6
0
        public void Should_return_summary_by_id_same_as_from_repository()
        {
            // Arrange
            var summaryId = 0;
            var expected  = SummaryDto.Create(_summaryRepository.Get(summaryId));

            // Act
            var result = _summaryService.Get(summaryId);

            // Assert
            Assert.That(result != null);
            Assert.That(result.Equals(expected));
        }
Example #7
0
        public SummaryDto Summary()
        {
            AssertAdmin();
            var summary = new SummaryDto();

            summary.ongoingGames = GamesService.AllGames.Count;
            using (var db = new Db.BgDbContext())
            {
                var today = DateTime.Now.Date;
                summary.playedGamesToday = db.Games.Count(g => g.Started > today);
                summary.playedGamesTotal = db.Games.Count();
                summary.reggedUsers      = db.Users.Count();
                summary.reggedUsersToday = db.Users.Count(u => u.Registered > today);
            }

            return(summary);
        }
        public async Task <JsonResult> getsummary([FromBody] SearchCondition scon)
        {
            //0. connect to shop db
            await setConnectionString(scon.ShopId); //set connection string for shop DB

            //1. create dto
            SummaryDto dto = new SummaryDto();

            //2. call helper method to get data set
            SummaryDetailDto select_detail = await GetSummaryHelper(scon.ShopId, scon.DateFrom, scon.DateTo);

            SummaryDetailDto compare_detail = await GetSummaryHelper(scon.ShopId, scon.Compare_DateFrom, scon.Compare_DateTo);

            //3. mapping values
            dto.ShopId = scon.ShopId;

            dto.Summary_Items = new List <SummaryItem>();

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Total Sales",
                Compare_Value = compare_detail.Total_Sales,
                Value         = select_detail.Total_Sales
            });

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Number Of Transactions",
                Compare_Value = compare_detail.Number_Of_Transactions,
                Value         = select_detail.Number_Of_Transactions
            });

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Total Refund",
                Compare_Value = compare_detail.Total_Refund,
                Value         = select_detail.Total_Refund
            });

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Total Discount",
                Compare_Value = compare_detail.Total_Discount,
                Value         = select_detail.Total_Discount
            });

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Avg. Sales Value",
                Compare_Value = compare_detail.Avg_Sales_Value,
                Value         = select_detail.Avg_Sales_Value
            });

            dto.Summary_Items.Add(new SummaryItem
            {
                Name          = "Avg. Item Per Sale",
                Compare_Value = compare_detail.Avg_Item_Per_Sale,
                Value         = select_detail.Avg_Item_Per_Sale
            });

            dto.Hourly_Summary = new HourlySummary
            {
                Name          = "Sales by Hour",
                Compare_Value = compare_detail.Hourly_Sales,
                Value         = select_detail.Hourly_Sales
            };

            dto.Payment_Summary = new PaymentSummary
            {
                Name          = "Payment Summary",
                Compare_Value = compare_detail.PaymentSum,
                Value         = select_detail.PaymentSum
            };

            dto.Custom_Data_Group = new CustomDataGroup
            {
                Name          = "Custom Data Group",
                Compare_Value = compare_detail.CustomDataSum,
                Value         = select_detail.CustomDataSum
            };

            //return dto
            return(Json(dto));
        }
Example #9
0
 public SummaryDto Delete(Int32 summaryId)
 {
     return(SummaryDto.Create(_summaryRepository.Delete(summaryId)));
 }
Example #10
0
 public SummaryDto GetForUser(Int32 userId)
 {
     return(SummaryDto.Create(_summaryRepository.GetForUser(userId)));
 }
Example #11
0
 public SummaryDto Get(Int32 summaryId)
 {
     return(SummaryDto.Create(_summaryRepository.Get(summaryId)));
 }