示例#1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,UserId,StartTime,EndTime,WorkedTime,ProjectId,Note,Billable,CreatedAt,UpdatedAt,UpdatedBy")] WorkHourModel workHourModel)
        {
            if (id != workHourModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workHourModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkHourModelExists(workHourModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(workHourModel));
        }
示例#2
0
        public async Task <bool> UpdateHour(WorkHourModel workHourModel)
        {
            var hour = await _context.StandardWorkHours.FindAsync(workHourModel.HourId);

            hour.NoOfHours             = workHourModel.NoOfHours;
            _context.Entry(hour).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> ModifyWorkHours(WorkHourModel workHourModel)
        {
            ViewBag.count = _attendenceRepository.AttendenceCount();
            bool success = await _attendenceRepository.UpdateHour(workHourModel);

            if (success == true)
            {
                return(RedirectToAction(nameof(ViewAttendence), new { isUpdate = true }));
            }
            return(View());
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,UserId,StartTime,EndTime,WorkedTime,ProjectId,Note,Billable,CreatedAt,UpdatedAt,UpdatedBy")] WorkHourModel workHourModel)
        {
            if (ModelState.IsValid)
            {
                workHourModel.Id = Guid.NewGuid();
                _context.Add(workHourModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workHourModel));
        }
示例#5
0
        public static void Initialize(WorkTimeContext context)
        {
            context.Database.EnsureCreated();

            //Look for any employees
            if (context.WorkHours.Any())
            {
                return; // DB Has been seed
            }

            var workHours = new WorkHourModel[]
            {
                new WorkHourModel {
                    UserId     = "606e998a-7d8f-494f-a46d-f141ce1e134c",
                    Billable   = true,
                    StartTime  = DateTime.UtcNow.AddDays(-1),
                    EndTime    = DateTime.UtcNow.AddDays(-1).AddHours(3),
                    WorkedTime = 3,
                    CreatedAt  = DateTime.UtcNow.AddDays(-1),
                    UpdatedAt  = DateTime.UtcNow.AddDays(-1).AddHours(3),
                    UpdatedBy  = "606e998a-7d8f-494f-a46d-f141ce1e134c",
                    ProjectId  = "1234567",
                    Note       = "This is data seed test note"
                },
                new WorkHourModel {
                    UserId     = "606e998a-7d8f-494f-a46d-f141ce1e134c",
                    Billable   = true,
                    StartTime  = DateTime.UtcNow.AddDays(-2),
                    EndTime    = DateTime.UtcNow.AddDays(-2).AddHours(4),
                    WorkedTime = 4,
                    CreatedAt  = DateTime.UtcNow.AddDays(-2),
                    UpdatedAt  = DateTime.UtcNow.AddDays(-2).AddHours(4),
                    UpdatedBy  = "606e998a-7d8f-494f-a46d-f141ce1e134c",
                    ProjectId  = "7654321",
                    Note       = "This is data seed test note 2"
                },
                new WorkHourModel {
                    UserId     = "0f513b0f-36eb-4b6c-92dd-e19ec06cdf4c",
                    Billable   = true,
                    StartTime  = DateTime.UtcNow.AddDays(-1),
                    EndTime    = DateTime.UtcNow.AddDays(-1).AddHours(10),
                    WorkedTime = 10,
                    CreatedAt  = DateTime.UtcNow.AddDays(-1),
                    UpdatedAt  = DateTime.UtcNow.AddDays(-1).AddHours(10),
                    UpdatedBy  = "0f513b0f-36eb-4b6c-92dd-e19ec06cdf4c",
                    ProjectId  = "123467",
                    Note       = "This is data seed test note"
                },
                new WorkHourModel {
                    UserId     = "0f513b0f-36eb-4b6c-92dd-e19ec06cdf4c",
                    Billable   = true,
                    StartTime  = DateTime.UtcNow.AddDays(-2),
                    EndTime    = DateTime.UtcNow.AddDays(-2).AddHours(12),
                    WorkedTime = 12,
                    CreatedAt  = DateTime.UtcNow.AddDays(-2),
                    UpdatedAt  = DateTime.UtcNow.AddDays(-2).AddHours(12),
                    UpdatedBy  = "0f513b0f-36eb-4b6c-92dd-e19ec06cdf4c",
                    ProjectId  = "123467",
                    Note       = "This is data seed test note"
                }
            };

            foreach (WorkHourModel w in workHours)
            {
                context.WorkHours.Add(w);
            }
            context.SaveChanges();
        }