public bool TrackTime(TimeLog timeLog, string lastName) { bool isValid = timeLog.WorkHours > 0 && timeLog.WorkHours <= 24 && !string.IsNullOrWhiteSpace(timeLog.LastName); var employee = _employeeRepository.GetEmployee(timeLog.LastName); if (!isValid || employee == null) { return(false); } if (employee is FreelancerEmployee) { if (DateTime.Now.AddDays(-2) > timeLog.Date) { return(false); } } if (employee is FreelancerEmployee || employee is StaffEmployee) { if (timeLog.LastName != lastName) { return(false); } } _timesheetRepository.Add(timeLog); return(true); }
private void Update(int resource_id, DateTime myDate, FormCollection coll) { timedb.DeleteTimesheet(resource_id, myDate); List <day> myEntries = new List <day>(); foreach (var item in coll) { if (item.ToString().Contains("r")) { if (coll[item.ToString()] != string.Empty) { myEntries.Add(new day { Day = int.Parse(item.ToString().Replace("r", "")), Year = myDate.Year, Month = myDate.Month, HoursWorked = decimal.Parse(coll[item.ToString()].ToString()) }); } } } foreach (var h in myEntries) { tbl_TimeSheet mytime = new tbl_TimeSheet(); mytime.Resource_ID = resource_id; mytime.Date = new DateTime(h.Year, h.Month, h.Day); mytime.Hours = (decimal)h.HoursWorked; timedb.Add(mytime); } timedb.Save(); }
public async Task <IActionResult> AddCompany(CompanyForRegisterDto companyForRegisterDto) { _repo.Add(companyForRegisterDto); if (await _repo.SaveAll()) { var companyToReturn = _mapper.Map <CompanyForListDto>(companyForRegisterDto); return(CreatedAtRoute("GetCompanies", companyToReturn)); } throw new Exception("Coś popszło nie tak podczas tworzenia firmy"); }
public Task CreateNewTask(Task task) { Task newTask = new Task { id = task.id, title = task.title, hours = task.hours }; _repository.Add(newTask); return(newTask); }
public bool TrackTime(TimeLog timeLog) { bool IsTimelogValid = timeLog.WorkingHours <= 24 && timeLog.WorkingHours > 0 && !string.IsNullOrWhiteSpace(timeLog.LastName); IsTimelogValid = IsTimelogValid && UserSession.Sessions.Contains(timeLog.LastName); if (IsTimelogValid) { _timesheetRepository.Add(timeLog); return(true); } return(false); }
public Timesheet Add(Timesheet newTimesheet) { var profileId = newTimesheet.ProfileId; var profile = _profileRepository.Get(profileId); var profileUserId = profile.UserId; var loggedInUserId = _userService.CurrentUserId; if (loggedInUserId != profileUserId) { throw new Exception("User cannot add a timesheet to this profile."); } newTimesheet.TimeIn = DateTime.Now; newTimesheet.TimeOut = DateTime.Now; return(_timesheetRepository.Add(newTimesheet)); }
public bool TrackTime(TimeLog timeLog) { bool isValid = timeLog.WorkingHours > 0 && timeLog.WorkingHours <= 24 && !string.IsNullOrWhiteSpace(timeLog.LastName); isValid = UserSessions.Sessions.Contains(timeLog.LastName) && isValid; if (!isValid) { return(false); } _timesheetRepository.Add(timeLog); return(true); }
public async Task <ActionResult <IEnumerable <TimesheetItem> > > Add(TimesheetItem item) { if (item == null) { throw new ArgumentNullException(); } var sessionData = _sessionService.GetSession(HttpContext); if (sessionData == null) { return(Unauthorized()); } return(Ok(await _timesheetRepository.Add(sessionData.UserId, item))); }
public bool TrackTime(TimeLog timeLog) { bool isValid = false; if (timeLog.WorkingTimeHours > 0 && timeLog.WorkingTimeHours <= 24 && timeLog.LastName != string.Empty) { if (UserSession.Sessions.Contains(timeLog.LastName)) { _timesheetRepository.Add(timeLog); isValid = true; } } return(isValid); }
public async Task <int> CreateAsync(CreateTimesheetRequest request) { var timesheet = new Timesheet { ProjectId = request.ProjectId, Activity = request.Activity, HourRate = request.HourRate, Hours = request.Hours, Comment = request.Comment, Date = request.Date }; if (request.EmployeeId == 0) { var currentEmployee = await _employeeRepository.FirstOrDefaultAsync(x => x.SystemUserId.Equals(_currentUserService.UserId)); timesheet.EmployeeId = currentEmployee.Id; } _timesheetRepository.Add(timesheet); return(await _unitOfWork.SaveChangesAsync()); }
public Timesheet Add(Timesheet Timesheet) { _timesheetRepo.Add(Timesheet); return(Timesheet); }