예제 #1
0
 public async Task <TimesheetRequestDTO> AddRequest(TimesheetRequestDTO request)
 {
     try
     {
         var req = new TimesheetRequest()
         {
             EmpId     = request.Empid,
             Reason    = request.Reason,
             Status    = request.Status,
             ManagerId = request.ManagerId
         };
         int requestid;
         using (var _context = new DatabaseContext())
         {
             _context.TimesheetRequest.Add(req);
             requestid = await _context.SaveChangesAsync();
         }
         request.Id = requestid;
         return(request);
     }
     catch (Exception e)
     {
         throw;
     }
 }
예제 #2
0
        private void OnSelect(DateTime _value)
        {
            if (TimeCount == 0 || TimeCount == 1)
            {
                Action = SelfServices.Timesheets.Action.Add;
                TimeCount++;
            }
            else
            {
                TimeCount++;
                if (Action.HasValue)
                {
                    if (Action == SelfServices.Timesheets.Action.Add)
                    {
                        Action    = SelfServices.Timesheets.Action.Add;
                        Title     = "Create timesheet";
                        Timesheet = new TimesheetRequest
                        {
                            Date     = _value.Date,
                            Activity = Activity.Code,
                            HourRate = HourRate.NormalWorkingDays,
                            Hours    = 8
                        };

                        ShowDialog = true;
                    }
                }
            }
        }
        private async Task Create(TimesheetRequest timesheetVm)
        {
            var timesheet = new CreateTimesheetRequest
            {
                HourRate  = timesheetVm.HourRate,
                ProjectId = timesheetVm.ProjectId,
                Activity  = timesheetVm.Activity,
                Hours     = timesheetVm.Hours,
                Comment   = timesheetVm.Comment,
                Date      = timesheetVm.Date == default ? DateTime.Now.Date : timesheetVm.Date
            };

            await _timesheetManager.CreateAsync(timesheet);
        }
예제 #4
0
        public async Task <TimesheetRequestDTO> UpdateRequest(TimesheetRequestDTO request)
        {
            try
            {
                using (var _context = new DatabaseContext())
                {
                    TimesheetRequest tr = await _context.TimesheetRequest.Where(x => x.RequestId == request.Id).FirstOrDefaultAsync <TimesheetRequest>();

                    {
                        tr.Status = request.Status;

                        _context.SaveChanges();
                    }
                    return(request);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
예제 #5
0
        private void OnClick(int id)
        {
            Title = "Update timesheet";

            var currentTimesheet = AllData.FirstOrDefault(x => x.Id == id);

            Timesheet = new TimesheetRequest
            {
                Id        = currentTimesheet.Id,
                ProjectId = currentTimesheet.ProjectId,
                HourRate  = currentTimesheet.HourRate,
                Activity  = currentTimesheet.Activity,
                Hours     = currentTimesheet.Hours,
                Date      = currentTimesheet.Date,
                Comment   = currentTimesheet.Comment
            };

            IsClickEdit = true;

            Action = SelfServices.Timesheets.Action.Edit;

            ShowDialog = true;
        }