protected AbstractCalendarEntry(DateTime from, DateTime to, EmployeeCalendar user, AbsenceType type) { From = from; To = to; AbsenceType = type; CalendarEmployee = user; }
/// <summary> /// Looks up some free meeting times by ID, LENGTH of requested meeting, /// EARLIEST and LATEST requested meeting, Office HOURS. /// Returns an object of EmployeeCalendar with an id, name and a list of calendarentries of meeting suggestions. /// </summary> /// <param name="id">The ID of the employee.</param> private EmployeeCalendar ReturnEmployeeCalendar(string id) { EmployeeCalendar employeeCalendar = new EmployeeCalendar(); Employee employee = new Employee(); List <string> stringList = new List <string>(); employee.Id = id; string line; file = new System.IO.StreamReader(path); while ((line = file.ReadLine()) != null) { tempCalendarEntry = new CalendarEntry(); if (!line.Equals("") && !line.Equals(" ")) { extracted = line.Substring(0, line.IndexOf(';')); if (extracted.Equals(id)) { extracted = line.Substring(extracted.Length + 1); if (!extracted.Any(char.IsDigit)) { employee.Name = extracted; } else { stringArray = extracted.Split(';'); extracted = stringArray[0] + stringArray[1]; tempStart = DateTime.Parse(stringArray[0], System.Globalization.CultureInfo.InvariantCulture); tempEnd = DateTime.Parse(stringArray[1], System.Globalization.CultureInfo.InvariantCulture); if (tempStart >= eDate && tempEnd <= lDate) { stringList.Add(extracted); } } } } } file.Close(); if (employee.Name == null) { employee.Name = "ID NOT FOUND IN REGISTER"; } finalEmployeeList.Add(employee); employeeCalendar.TheEmployee = finalEmployeeList; employeeCalendar.TheListOfEntries = Sort.ReturnSortedList(stringList); finalList = IntervalList(employeeCalendar.TheListOfEntries, eDate, lDate); employeeCalendar.TheListOfEntries = finalList; return(employeeCalendar); }
public void DeleteEH(string dayID, string employeeId) { try { //Step 1 Code to delete the object from the database EmployeeCalendar n = new EmployeeCalendar(); n.dayId = dayID; n.employeeId = Convert.ToInt32(employeeId); PostRequest <EmployeeCalendar> req = new PostRequest <EmployeeCalendar>(); req.entity = n; PostResponse <EmployeeCalendar> res = _employeeService.ChildDelete <EmployeeCalendar>(req); if (!res.Success) { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, res.Summary).Show(); return; } else { //Step 2 : remove the object from the store employeeCalenderyStore.Reload(); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
public Vacation(DateTime from, DateTime to, EmployeeCalendar user, bool isPaid) : base(from, to, user, AbsenceType.Vacation) { IsPaid = isPaid; }
public Illness(DateTime from, DateTime to, EmployeeCalendar user) : base(from, to, user, AbsenceType.Illness) { }
public SickDay(DateTime from, DateTime to, EmployeeCalendar user) : base(from, to, user, AbsenceType.SickDay) { }
public async Task <IActionResult> AddOrUpdateEmployeeCalendar(int employeeId, int calendarId, bool isOpenCalendar, DateTime startDate, DateTime endDate, ContractWorkTime workTime, AttendanceProof attendanceProof, string note) { try { var newData = new EmployeeCalendar { Id = calendarId, StartDate = startDate, EndDate = isOpenCalendar? default(DateTime?) : endDate, ContractWorkTime = workTime, AttendanceProof = attendanceProof, EmployeeId = employeeId, Note = note, }; if (User.Identity.IsAuthenticated) { newData.UserId = User.Identity.Name.ConvertToInteger(); } if (newData.Id == 0) { var saveResult = await _employeesCalendarsManager.InsertNewAsync(newData); if (saveResult.Status == RepositoryActionStatus.Created) { return(Json("ok")); } else { return(Json(new { errors = "Error" })); } } else { var currentData = await _employeesCalendarsManager.GetByIdAsync(newData.Id); if (currentData == null) { return(Json(new { errors = "NotFound" })); } currentData.StartDate = newData.StartDate; currentData.EndDate = newData.EndDate; currentData.ContractWorkTime = newData.ContractWorkTime; currentData.AttendanceProof = newData.AttendanceProof; currentData.Note = newData.Note; currentData.UserId = newData.UserId; var updateResult = await _employeesCalendarsManager.UpdateDataItem(currentData); if (updateResult.Status == RepositoryActionStatus.Updated) { return(Json("ok")); } else { return(Json(new { errors = "Error" })); } } } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(ex.Message)) { if (ex.Message.Contains("before")) { return(Json(new { errors = "enddate" })); } } return(Json(new { errors = "Error" })); } }
protected void SaveEH(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; EmployeeCalendar b = JsonConvert.DeserializeObject <EmployeeCalendar>(obj); b.dayId = b.dayIdDt.ToString("yyyyMMdd"); b.employeeId = Convert.ToInt32(Request.QueryString["employeeId"]); b.caName = e.ExtraParams["caName"]; b.scName = e.ExtraParams["scName"]; if (ADDNewRecord.Text.Equals("1")) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <EmployeeCalendar> request = new PostRequest <EmployeeCalendar>(); request.entity = b; PostResponse <EmployeeCalendar> r = _employeeService.ChildAddOrUpdate <EmployeeCalendar>(request); // b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store this.employeeCalenderyStore.Reload(); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditEHwindow.Close(); /* RowSelectionModel sm = this.employeeCalenderGrid.GetSelectionModel() as RowSelectionModel; * sm.DeselectAll(); * sm.Select(b.recordId.ToString()); * EHCount.Text = (Convert.ToInt32(EHCount.Text) + 1).ToString(); */ } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { // int index = Convert.ToInt32(id);//getting the id of the record PostRequest <EmployeeCalendar> request = new PostRequest <EmployeeCalendar>(); request.entity = b; PostResponse <EmployeeCalendar> r = _employeeService.ChildAddOrUpdate <EmployeeCalendar>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); employeeCalenderyStore.Reload(); this.EditEHwindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
/// <summary> /// Return of an HttpResponseMessage to be sent back to client in accordance with several conditions. /// Parameters are passed on from previous GET and POST methods. /// </summary> /// <param name="length">The LENGTH of the requested meeting</param> /// <param name="earliest">The EARLIEST requested meeting</param> /// <param name="latest">The LATEST requested meeting</param> /// <param name="hours">The office HOURS for meetings</param> /// <param name="ids">The ID/IDs of the employee/employees.</param> /// <param name="id">The ID of the employee.</param> private HttpResponseMessage ReturnResluts(int length, string earliest, string latest, string hours, [FromUri] string[] ids = null) { //System.Diagnostics.Debug.WriteLine("ids: " + ids.Length); earliest = uriStringChars(earliest); latest = uriStringChars(latest); if (ids.Length == 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "No ID provieded")); } else if (IsListNotReady(ids)) { errorIdList.Insert(0, "IDs not found or not valid"); HttpResponseMessage resp = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(errorIdList), System.Text.Encoding.UTF8, "application/json") }; return(resp); } else if (!IsLengthOk(length)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Length error: " + length)); } else if (!IsDateOk(earliest)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Earliest date request error: " + earliest)); } else if (!IsDateOk(latest)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Latest date request error: " + latest)); } else if (!IsHoursOk(hours)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Office hours error: " + hours)); } else { eDate = DateTime.Parse(earliest, System.Globalization.CultureInfo.InvariantCulture); lDate = DateTime.Parse(latest, System.Globalization.CultureInfo.InvariantCulture); if (lDate < eDate.AddMinutes(length)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Earliest: " + eDate + "; Length: " + length + "; Latest: " + latest)); } else { EmployeeCalendar e = new EmployeeCalendar(); finalEmployeeList = new List <Employee>(); this.length = length; this.hours = hours; finalList = new List <CalendarEntry>(); ids = ids.Distinct().ToArray(); for (int i = 0; i < ids.Length; i++) { e = ReturnEmployeeCalendar(ids[i]); if (i == 1) { moreIDs = true; } } return(Request.CreateResponse(HttpStatusCode.OK, e)); } } }