Esempio n. 1
0
        public static void Main()
        {
            var forms = DeclarationForm.ParseMultiple(File.ReadAllLines("input.txt"));

            Console.WriteLine($"Part 1: the sum is {forms.Sum(f => f.Answers.Values.Count)}.");
            Console.WriteLine($"Part 2: the sum is {forms.Sum(f => f.Answers.Values.Where(c => c == f.GroupSize).Count())}.");
        }
Esempio n. 2
0
        public async Task CreateFormForUser(string EmployeeId, string month, int year)
        {
            var newForm = new DeclarationForm
            {
                EmployeeId       = EmployeeId,
                Month            = month,
                Year             = year,
                uniqueId         = GenerateUniqueId(),
                Approved         = "Pending",
                Submitted        = false,
                TotalWorkedHours = 0,
                TotalOvertime    = 0,
                TotalSickness    = 0,
                TotalVacation    = 0,
                TotalHoliday     = 0,
                TotalTraining    = 0,
                TotalOther       = 0,
                DateCreated      = DateTime.Now
            };

            await context.DeclarationForms.AddAsync(newForm);

            await context.SaveChangesAsync();
        }
Esempio n. 3
0
 public void SetUp()
 {
     _declarationForm = new DeclarationForm(_input);
 }
Esempio n. 4
0
 public IActionResult AddDeclareJob([FromBody] DeclarationForm form)
 {
     //_core.DeclearQueue.Enqueue(form);
     return(Ok());
 }
Esempio n. 5
0
        public async Task <DeclarationFormModel> GetFormModelFromEntity(DeclarationForm entity)
        {
            List <HourRowModel> ListOfHourRowModels = new List <HourRowModel>();

            foreach (HourRow hourRow in entity.HourRows)
            {
                HourRowModel newHourRowModel = new HourRowModel
                {
                    HourRowId        = hourRow.HourRowId,
                    EmployeeId       = entity.EmployeeId,
                    Date             = hourRow.Date,
                    Worked           = hourRow.Worked,
                    Overtime         = hourRow.Overtime,
                    Sickness         = hourRow.Sickness,
                    Vacation         = hourRow.Vacation,
                    Holiday          = hourRow.Holiday,
                    Training         = hourRow.Training,
                    Other            = hourRow.Other,
                    OtherExplanation = hourRow.OtherExplanation
                };
                ListOfHourRowModels.Add(newHourRowModel);
            }

            var selectedEmployee = await context.Users.SingleAsync(p => p.Id == entity.EmployeeId);

            var castedEmployee = (Employee)selectedEmployee;
            var employeeName   = castedEmployee.FirstName + " " + castedEmployee.LastName;

            string month = "";

            if (MonthConverter.ConvertMonthToInt(entity.Month) < 10)
            {
                month = 0 + MonthConverter.ConvertMonthToInt(entity.Month).ToString();
            }
            else
            {
                month = MonthConverter.ConvertMonthToInt(entity.Month).ToString();
            }
            string yearString      = entity.Year.ToString();
            string monthYearString = yearString + month;
            int    monthYear       = Convert.ToInt32(monthYearString);

            var newModel = new DeclarationFormModel
            {
                FormId           = entity.DeclarationFormId,
                HourRows         = ListOfHourRowModels,
                EmployeeId       = entity.EmployeeId,
                EmployeeName     = employeeName,
                Month            = entity.Month,
                Year             = entity.Year,
                monthyear        = monthYear,
                Approved         = entity.Approved,
                Submitted        = entity.Submitted,
                Comment          = entity.Comment,
                uniqueId         = entity.uniqueId,
                TotalWorkedHours = entity.TotalWorkedHours,
                TotalOvertime    = entity.TotalOvertime,
                TotalSickness    = entity.TotalSickness,
                TotalVacation    = entity.TotalVacation,
                TotalHoliday     = entity.TotalHoliday,
                TotalTraining    = entity.TotalTraining,
                TotalOther       = entity.TotalOther,
                DateCreated      = entity.DateCreated
            };

            return(newModel);
        }
Esempio n. 6
0
        public async Task CreateForm(string employeeId)
        {
            var entities        = context.DeclarationForms.Where(p => p.EmployeeId == employeeId).ToList();
            var formModels      = EntitiesToDeclarationFormModels(entities);
            var ascendingModels = formModels.OrderBy(p => p.monthyear).ToList();

            if (formModels.Count() > 0)
            {
                var LastMonth = GetFormFromGap(ascendingModels);
                var monthInt  = 0;
                var entity    = new DeclarationFormModel();

                if (LastMonth != null)
                {
                    entity   = LastMonth;
                    monthInt = MonthConverter.ConvertMonthToInt(LastMonth.Month) + 1;
                }
                else
                {
                    entity   = ascendingModels[ascendingModels.Count() - 1];
                    monthInt = MonthConverter.ConvertMonthToInt(entity.Month) + 1;
                }

                if (monthInt == 13)
                {
                    monthInt = 1;
                }
                var monthString = MonthConverter.ConvertIntToMaand(monthInt);
                var year        = entity.Year;
                if (monthString == "Januari")
                {
                    year += 1;
                }

                if (monthInt == 1)
                {
                    monthInt = 13;
                }
                if (monthInt == 2 && DateTime.Now.Month != 1)
                {
                    monthInt = 14;
                }
                if (monthInt <= DateTime.Now.Month + 1)
                {
                    var form = new DeclarationForm
                    {
                        EmployeeId       = employeeId,
                        Month            = monthString,
                        Year             = year,
                        uniqueId         = GenerateUniqueId(),
                        Approved         = "Pending",
                        Submitted        = false,
                        TotalWorkedHours = 0,
                        TotalOvertime    = 0,
                        TotalSickness    = 0,
                        TotalVacation    = 0,
                        TotalHoliday     = 0,
                        TotalTraining    = 0,
                        TotalOther       = 0,
                        DateCreated      = DateTime.Now
                    };
                    await context.DeclarationForms.AddAsync(form);
                }
                else
                {
                    return;
                }
            }
            else
            {
                var form = new DeclarationForm
                {
                    EmployeeId       = employeeId,
                    Month            = MonthConverter.ConvertIntToMaand(DateTime.Now.Month),
                    Year             = DateTime.Now.Year,
                    uniqueId         = GenerateUniqueId(),
                    Approved         = "Pending",
                    Submitted        = false,
                    TotalWorkedHours = 0,
                    TotalOvertime    = 0,
                    TotalSickness    = 0,
                    TotalVacation    = 0,
                    TotalHoliday     = 0,
                    TotalTraining    = 0,
                    TotalOther       = 0,
                    DateCreated      = DateTime.Now
                };
                await context.DeclarationForms.AddAsync(form);
            }
            await context.SaveChangesAsync();
        }