private void btnReportAlphabetical_Click(object sender, EventArgs e) { Vacations vacForm = new Vacations(); vacForm.gdcVacation.DataSource = _vacationBL.GetAll().OrderBy(v => v.Employee.DisplayName); vacForm.Show(); }
private void btnReportChronological_Click(object sender, EventArgs e) { Vacations vacForm = new Vacations(); vacForm.gdcVacation.DataSource = _vacationBL.GetAll(); vacForm.Show(); }
public void ApplyForVacation() { using (var businessapp = new CompanyBusinessAppDbContext()) { Console.WriteLine("Enter Employee Code"); int EmpCode = Convert.ToInt32(Console.ReadLine()); int EmployeeId = businessapp.Employees.SingleOrDefault <Employees>(t => t.EmployeeCode == EmpCode).EmployeeId; if (EmployeeId != 0) { int EmpId = businessapp.Vacations.Count <Vacations>(t => t.EmployeeId == EmployeeId); if (EmpId == 0) { var applyforvacation = new Vacations { EmployeeId = EmployeeId }; businessapp.Vacations.Add(applyforvacation); businessapp.SaveChanges(); Console.WriteLine("You are successfully applied for Vacation"); } else { Console.WriteLine("Employee is Already On Vacation"); } } else { Console.WriteLine("Invalid Employee Code"); Console.WriteLine("Please Try Again"); } } }
private void btnReportDate_Click(object sender, EventArgs e) { Vacations vacForm = new Vacations(); vacForm.gdcVacation.DataSource = _vacationBL.GetByDate(dteReportFrom.DateTime, dteReportTo.DateTime); vacForm.Show(); }
private void EnsureVacationIsNotProcessed(Vacations vacation) { if (vacation.VacationProcesses.Any()) { throw new Exception($"Vacation with id {vacation.Id} have been already processed and cannot be changed"); } }
public static IHttpContext vacationEdit(IHttpContext context, string id) { try { ValidationBuilder valBuilder = new ValidationBuilder(); ValidationCollection valCollection; string[] valArray = { "name=Start,isRequired=,isDateTime=", "name=End,isRequired=,isDateTime=", }; valCollection = valBuilder.build(valArray); Vacations vac = BaseController.getUserInput <Vacations>(context, valCollection); vac.Id = uint.Parse(id); Vacations.edit(vac.Id, vac); context.Response.SendResponse(""); } catch (Exception ex) { context.Response.StatusCode = HttpStatusCode.InternalServerError; context.Response.SendResponse(ex.Message); } return(context); }
public int AddVacations(Vacations data) { var res = _context.Vacations.Add(data); _context.SaveChanges(); return(res.Entity.id); }
public ActionResult Save(string id, string name, string description, string startDate, string endDate) { var Id = Convert.ToInt32(id); var vacationsList = Session["Vacations"] as List <Vacations>; var exist = vacationsList.Any(x => x.id == Id); var vacation = new Vacations(); vacation.id = Id; vacation.name = name; vacation.description = description; vacation.startDate = startDate; vacation.endDate = endDate; if (exist) { vacationsList.RemoveAll(x => x.id == Id); } vacationsList.Add(vacation); Session["Vacations"] = vacationsList; return(Json(vacation.id, JsonRequestBehavior.AllowGet)); }
private void btnReportDispatcher_Click(object sender, EventArgs e) { Vacations vacForm = new Vacations(); vacForm.gdcVacation.DataSource = _vacationBL.GetByDispatcher((TIS.Model.Internal.Employee)glouReportDispatcher.GetSelectedDataRow()); vacForm.Show(); }
public bool IsOnVacation(DateTime date) { if (Vacations?.Count > 0) { return(Vacations.Any(v => v.UserID == Id && v.Status == RequestStatus.Approved && v.StartDate.Date <= date.Date && v.EndDate.Date >= date.Date && new VacationViewModel(v).TotalDays > 0.5)); } return(false); }
public VacationType?GetCurrentVacationType(DateTime date) { if (Vacations?.Count > 0) { return(Vacations.FirstOrDefault(v => v.UserID == this.Id && v.Status == RequestStatus.Approved && v.StartDate <= date.Date && v.EndDate >= date.Date && new VacationViewModel(v).TotalDays >= 1.0)?.VacationType); } return(null); }
public bool WasOnVacationYesterday() { if (Vacations?.Count > 0) { DateTime date = DateTime.Today.AddDays(-1).Date; return(Vacations.Any(v => v.UserID == this.Id && v.Status == RequestStatus.Approved && v.StartDate <= date && v.EndDate >= date && new VacationViewModel(v).TotalDays >= 1.0)); } return(false); }
public static void UpdateEDD() { //one mass update per time lock (_lockEDD) { if (DateTime.Compare(_EDDDate, DefectBase.LastGlobalModifier) > 0) { return; } //cache all vacations List <DefectBase> vacs = Vacations.EnumCloseVacations(DateTime.Today, 365); DefectBase d = new DefectBase(); foreach (var u in DefectUser.Enum()) { if (!u.ACTIVE) { continue; } string sid = u.ID.ToString(); List <DateTime> vacDates = new List <DateTime>(); foreach (var v in vacs) { if (v.AUSER == sid) { vacDates.Add(DateTime.ParseExact(v.DATE, IdBasedObject.defDateFormat, CultureInfo.InvariantCulture)); } } DateTime dat = DateTime.Today.AddDays(1); foreach (var task in d.EnumPlan(u.ID)) { while (dat.DayOfWeek == DayOfWeek.Saturday || dat.DayOfWeek == DayOfWeek.Sunday) { dat = dat.AddDays(1); } while (vacDates.Exists(x => dat.Date.CompareTo(x) == 0)) { dat = dat.AddDays(1); } int hours = Math.Max(task.ESTIM - task.SPENT, 0) + dat.Hour; dat = dat.AddHours(-dat.Hour); int days = hours / 8; hours = hours % 8; dat = dat.AddDays(days); dat = dat.AddHours(hours); task.SetEDD(dat.Date); } } _EDDDate = DateTime.Now; } }
private Vacations GetNewInstance(Vacations vacations, AbsenceType absenceType, DateTime date) { return(new Vacations { AbsenseType = absenceType, AbsenseTypeId = vacations.AbsenseTypeId, CreatedAt = DateTimeOffset.Now, Date = date, State = vacations.State }); }
public static void ResetAllData() { Admin = null; Employee = null; Department = null; City = null; Country = null; FiredEmployee = null; Vacation = null; Message = null; Request = null; }
protected void btnSubmit_Click(object sender, EventArgs e) { DateTime Returning = DateTime.Now; switch (Convert.ToDateTime(txtDateTO.Text).ToString("dddd")) { case "Friday": Returning = Convert.ToDateTime(txtDateTO.Text).AddDays(2); break; case "Saturday": Returning = Convert.ToDateTime(txtDateTO.Text).AddDays(1); break; default: Returning = Convert.ToDateTime(txtDateTO.Text); break; } ; Vacations vacations = new Vacations { Title = txtTitle.Text, Employee_Name = txtName.Text, Department_id = (ddlDepartment.SelectedValue == "" ? 0 : Convert.ToInt32(ddlDepartment.SelectedValue)), Date_From = Convert.ToDateTime(txtDateFrom.Text), Date_To = Convert.ToDateTime(txtDateTO.Text), Notes = txtNotes.Text, Submission_Date = DateTime.Now, Returning = Returning }; if (Page.IsValid && Convert.ToDateTime(txtDateFrom.Text) < Convert.ToDateTime(txtDateTO.Text)) { db.Vacation.Add(vacations); db.SaveChanges(); txtDateTO.Text = ""; txtName.Text = ""; txtNotes.Text = ""; txtTitle.Text = ""; txtDateFrom.Text = ""; lblStatus.ForeColor = System.Drawing.Color.Green; lblStatus.Text = "Your Vacation is Received successfully"; } else { lblStatus.ForeColor = System.Drawing.Color.Red; lblStatus.Text = "date to must be lower than date from, not saved!"; } }
public List <VacationDto> GetVacationsCalendar() { return(Vacations.Select(v => new VacationDto { Start = v.StartDate, End = v.EndDate, Title = string.IsNullOrEmpty(v.Title) ? Users.First(u => u.Id == v.UserId).FullName : $"{Users.First(u => u.Id == v.UserId).FullName}: {v.Title}" }) .ToList()); }
public static IHttpContext vacationDelete(IHttpContext context, string id) { try { Vacations.delete(uint.Parse(id)); context.Response.SendResponse(""); } catch (Exception ex) { context.Response.StatusCode = HttpStatusCode.InternalServerError; context.Response.SendResponse(ex.Message); } return(context); }
public static IHttpContext vacationGet(IHttpContext context, string id) { try { var vac = Vacations.get(uint.Parse(id)); context.Response.SendResponse(JsonConvert.SerializeObject(vac)); } catch (Exception ex) { context.Response.StatusCode = HttpStatusCode.InternalServerError; context.Response.SendResponse(ex.Message); } return(context); }
private Vacations CreateVacationFromCalendarEvent( CalendarEvent @event, DateTimeOffset timestamp, string updatedBy) { var vacation = new Vacations { EmployeeId = int.Parse(@event.EmployeeId), RaisedAt = timestamp, Start = @event.Dates.StartDate.Date, End = @event.Dates.EndDate.Date, Type = (int)VacationType.Regular }; var updatedById = int.Parse(updatedBy); if (@event.Status == VacationStatuses.Cancelled) { var vacationCancellation = new VacationCancellations { CancelledAt = timestamp, CancelledById = updatedById }; vacation.VacationCancellations.Add(vacationCancellation); } else if (@event.Status == VacationStatuses.Rejected) { var rejectedApproval = new VacationApprovals { ApproverId = updatedById, TimeStamp = timestamp, Status = (int)VacationApprovalStatus.Declined }; vacation.VacationApprovals.Add(rejectedApproval); } else if (@event.Status == VacationStatuses.Approved) { var finalApproval = new VacationApprovals { ApproverId = updatedById, TimeStamp = timestamp, Status = (int)VacationApprovalStatus.Approved, IsFinal = true }; vacation.VacationApprovals.Add(finalApproval); } return(vacation); }
public async void UpdateActivity() { this.Vacations.Clear(); this.Vacation.TotalDays = 0; this.TDays = 0; var items = await App.Database._spentVacations.GetSpentVacationsPeriodsAsync(Vacation.IDEmployee, Vacation.RefYear); foreach (var item in items) { Vacations.Add(item); this.TDays += item.TotalDays; } this.Vacation.TotalDays = this.TDays; }
public bool UpdateVacations(int id, Vacations data) { var res = _context.Vacations.FirstOrDefault(x => x.id == id); if (res == null) { return(false); } res.vacationEntitlementId = data.vacationEntitlementId; res.accrualId = data.accrualId; res.dateStart = data.dateStart; res.dateEnd = data.dateEnd; _context.SaveChanges(); return(true); }
void ExecuteSaveVacationCommand() { var absence = new Absence { From = From, To = To, Employee = Employee.Model, Description = Description, AbsenceType = AbsenceType }; var vacationWrapper = new AbsenceWrapper(absence); _dataService.AddAbsences(absence); Vacations.Add(vacationWrapper); }
public bool Add(List <int> personsIds, List <DateTime> vacationsDates, Vacations vacation) { if (!vacationsDates.Any()) { _validationService.Add("Date", Enumerations.ErrorType.Error, ErrorMessages.DatesRequired); return(false); } try { var persons = _context.Persons.Include(p => p.Vacations).Where(p => personsIds.Contains(p.Id)).ToList(); var absenseType = _context.AbsenceTypes.FirstOrDefault(a => a.Id.Equals(vacation.AbsenseTypeId)); foreach (var person in persons) { if (!ValidateMaxDays(person.Vacations.Count(v => v.Date.Year.Equals(vacation.Date.Year)))) { foreach (var date in vacationsDates) { if (!date.ValidateExistingDate(person.Vacations.Select(v => v.Date))) { var newVacation = GetNewInstance(vacation, absenseType, date); person.Vacations.Add(newVacation); _context.Update(person); } else { _validationService.Add("Date", Enumerations.ErrorType.Error, string.Format(ErrorMessages.ExistingDateBulk, $"{person.Name} {person.LastName}", date.ToShortDateString())); } } } else { _validationService.Add("Date", Enumerations.ErrorType.Error, string.Format(ErrorMessages.MaxDays, $"{person.Name} {person.LastName}")); } } _context.SaveChanges(); return(true); } catch (Exception ex) { _validationService.Add("Date", Enumerations.ErrorType.Error, (ex.InnerException ?? ex).Message); return(false); } }
public async Task CreateAsync(CreateVacationViewModel model) { var vocation = new Vacations { Tittle = model.Tittle, FromDate = model.FromDate, ToDate = model.ToDate, CreatedOn = DateTime.UtcNow, IsDeleted = false, UserId = model.UserId }; await this.vocationsRepository.AddAsync(vocation); await this.vocationsRepository.SaveChangesAsync(); }
public static List <Roommate> Enum() { var Vacs = Vacations.TodayVacations(); List <Roommate> ls = new List <Roommate>(); foreach (DataRow r in DBHelper.GetRows(_sql)) { Roommate d = new Roommate(r); Vacation v = Vacs.Find(x => x.UserId == d.ID); if (v != null) { d.STATUS = v.Sick ? (int)userstatus.sick : (int)userstatus.vacation; } ls.Add(d); } return(ls); }
public Proposals CreateVacationProposal(VacationProposalViewModel model, Guid initiatorId) { Processes process = Db.Processes.Include(p => p.Stages) .First(p => p.ProcessType == (int)ProcessesTypes.Vacation); var vacation = new Vacations(initiatorId, model); var proposal = new Proposals(process, initiatorId, title: process.Name, isUrgently: model.IsUrgently, vacationId: vacation.Id); var status = new Statuses(model.DecisionMakerId, proposal.Id); Db.Vacations.Add(vacation); Db.Proposals.Add(proposal); Db.Statuses.Add(status); proposal.Initiator = Db.Users.FirstOrDefault(user => user.Id == initiatorId); return(proposal); }
public IActionResult PostVacations(Vacations data) { try { var res = _repository.AddVacations(data); if (res == -1) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }
public IActionResult PutVacations(int id, [FromBody] Vacations data) { try { var res = _repository.UpdateVacations(id, data); if (!res) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }
public ActionResult Create(Vacations Vacation) { var vacationsList = Session["Vacations"] as List <Vacations>; var emp = new Vacations(); emp.id = vacationsList.LastOrDefault().id + 1; emp.name = Vacation.name; emp.description = Vacation.description; emp.startDate = Vacation.startDate; emp.endDate = Vacation.endDate; vacationsList.Add(emp); Session["Vacations"] = vacationsList; return(Json(vacationsList, JsonRequestBehavior.AllowGet)); }