public IActionResult Add()
        {
            //AddTimesheetViewModel addTimesheetViewModel = new AddTimesheetViewModel();
            AddTimesheetViewModel addTimesheetViewModel = new AddTimesheetViewModel(context.TimesheetDays.ToList());

            return(View(addTimesheetViewModel));
        }
        public IActionResult Add(AddTimesheetViewModel addTimesheetViewModel)
        {
            TimesheetDay newTimesheetDay =
                context.TimesheetDays.Single(c => c.ID == addTimesheetViewModel.DayOfTheWeekID);
            //context.TimesheetDays.

            Timesheet newTimesheet = new Timesheet
            {
                Name         = addTimesheetViewModel.Name,
                DayOfTheWeek = newTimesheetDay
            };

            context.Timesheets.Add(newTimesheet);
            context.SaveChanges();

            return(Redirect("/Timesheet"));
        }
Esempio n. 3
0
 public void AddUpdate(AddTimesheetViewModel vm)
 {
     if (vm != null && vm.EmployeeNumber > 0 && vm.SelectedMonth > 0 && vm.WorkingHours > 0)
     {
         ts.TimesheetDBContext db = DBContext;
         var ts = db.Timesheet.Where(x => x.EmployeeNumber == vm.EmployeeNumber && x.Month == vm.SelectedMonth).FirstOrDefault();
         if (ts != null && ts.EmployeeNumber > 0)
         {
             ts.WorkingHours = vm.WorkingHours;
         }
         else
         {
             db.Timesheet.Add(new Data.Entities.Timesheet()
             {
                 EmployeeNumber = vm.EmployeeNumber, Month = vm.SelectedMonth, WorkingHours = vm.WorkingHours
             });
         }
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public ActionResult AddPV(AddTimesheetViewModel vm)
 {
     new TimesheetRepository().AddUpdate(vm);
     return(RedirectToAction("Index"));
 }