Beispiel #1
0
 private void ApplyStatusAndProjectHours(IForecastRegistrationViewModel vm, ForecastsByUserAndMonthResponse response)
 {
     /* We dont want app to crash due to this.
      * Just try and dont vomit if an error occurs
      * **/
     try
     {
         TryApplyDayLayout(DayOfWeek.Monday, vm, response.ForecastMonth.ForecastDtos);
         TryApplyDayLayout(DayOfWeek.Tuesday, vm, response.ForecastMonth.ForecastDtos);
         TryApplyDayLayout(DayOfWeek.Wednesday, vm, response.ForecastMonth.ForecastDtos);
         TryApplyDayLayout(DayOfWeek.Thursday, vm, response.ForecastMonth.ForecastDtos);
         TryApplyDayLayout(DayOfWeek.Friday, vm, response.ForecastMonth.ForecastDtos);
     }
     catch (Exception exp)
     {
         var msg = new StringBuilder()
                   .AppendLine("I had problems trying to copy hours.")
                   .AppendLine("Hours will not be copied.")
                   .AppendLine("Please contact someone.")
                   .AppendLine("Sry...")
                   .AppendLine()
                   .AppendLine(exp.ToString());
         _commonDialogs.Error(msg.ToString());
     }
 }
        private ForecastsByUserAndMonthResponse GetValue(ForecastsByUserAndMonthRequest request)
        {
            var result = new ForecastsByUserAndMonthResponse();

            var forecastMonth = _forecastMonthRepository.GetByUserAndMonth(request.UserId, request.ForecastMonth, request.ForecastYear);

            result.ForecastMonth = ToForecastDtoObject(forecastMonth, request);

            var holidays = _holidayRepository.GetByMonth(request.HolidayMonth, request.HolidayYear);

            result.Holidays = holidays.Select(ToHolidayDtoObject).ToList();

            result.ProjectForecastTypeId = _domainSettings.ProjectForecastTypeId;

            return(result);
        }
        public void Write_WritesValuesAsExpected()
        {
            var response = new ForecastsByUserAndMonthResponse
            {
                // Arrange
                ForecastMonth = new ForecastMonthDto
                {
                    Id           = 135,
                    Month        = 246,
                    Year         = 2012,
                    CreatedById  = 43,
                    IsLocked     = false,
                    UserId       = 34,
                    ForecastDtos = new Collection <ForecastDto>
                    {
                        new ForecastDto {
                            Date = new DateTime(), Id = 999, DedicatedForecastTypeHours = 5, ForecastType = new ForecastTypeDto {
                                Name = "Mah type"
                            }
                        },
                        new ForecastDto {
                            Date = new DateTime(), Id = 888, DedicatedForecastTypeHours = 11, ForecastType = new ForecastTypeDto {
                                Name = "Ooh type"
                            }
                        }
                    }
                },

                Holidays = new List <HolidayDto>
                {
                    new HolidayDto {
                        Date = new DateTime(), Description = "Weee"
                    },
                    new HolidayDto {
                        Date = new DateTime(), Description = "Woo"
                    },
                    new HolidayDto {
                        Date = new DateTime(), Description = "Waa"
                    },
                    new HolidayDto {
                        Date = new DateTime(), Description = "Wuuuu"
                    }
                }
            };

            // Act
            var result = ObjectDumper.DumpToString(response);

            // Assert
            Assert.That(result, Contains.Substring("Mah type"));
            Assert.That(result, Contains.Substring("Ooh type"));
            Assert.That(result, Contains.Substring("135"));
            Assert.That(result, Contains.Substring("246"));
            Assert.That(result, Contains.Substring("2012"));
            Assert.That(result, Contains.Substring("43"));
            Assert.That(result, Contains.Substring("34"));
            Assert.That(result, Contains.Substring("999"));
            Assert.That(result, Contains.Substring("888"));
            Assert.That(result, Contains.Substring("Weee"));
            Assert.That(result, Contains.Substring("Woo"));
            Assert.That(result, Contains.Substring("Waa"));
            Assert.That(result, Contains.Substring("Wuuuu"));
        }