private void btnAddTimeInterval_Click_1(object sender, EventArgs e) { try { using (var controller = this.iFactory.GetController <ManageScheduleHandler>()) { DataGridViewRow row = dgvDateInterval.CurrentRow; ScheduleDTO dateInterval = dgvDateInterval.GetItem(row.Index); ScheduleEntryDTO timeInterval = new ScheduleEntryDTO(); IAddModifyViewForm ventana = new AgregarModificarIntervaloTiempo(this.iFactory); ventana.Add((IDTO)timeInterval); DialogResult resultado = ventana.ShowForm(); if (resultado == DialogResult.OK) { dateInterval.ActiveHours.Add(timeInterval); } } } catch { throw; } //TODO revisar esto }
public void DateIntervalController_TimeIntervalAdd() { // Arrange int lId = 1; TimeSpan lNewEnd = new TimeSpan(22, 0, 0); TimeSpan lNewStart = new TimeSpan(20, 0, 0); ManageScheduleHandler lController = new ManageScheduleHandler(); ScheduleDTO lResult; ScheduleDTO lDto; ScheduleEntryDTO lNewTime; // Act lDto = lController.GetSchedule(lId); lNewTime = new ScheduleEntryDTO() { EndTime = lNewEnd, StartTime = lNewStart }; lDto.ActiveHours.Add(lNewTime); lController.ModifySchedule(lDto); // Assert lResult = lController.GetSchedule(lId); this.AssertAreEqualForAdding(lDto, lResult); }
public void DeleteScheduleEntry(Token token, ScheduleEntryDTO entry) { var securityInfo = SecurityManager.EnsureAuthentication(token); var service = new ScheduleEntryService(Session, securityInfo, Configuration); service.DeleteScheduleEntry(entry); }
public ScheduleEntryDTO SaveScheduleEntry(Token token, ScheduleEntryDTO entry) { var securityInfo = SecurityManager.EnsureAuthentication(token); var service = new ScheduleEntryService(Session, securityInfo, Configuration); return(service.SaveScheduleEntry(entry)); }
void IAddModifyViewForm.Add(IDTO pNewTimeInterval) { this.dtpStartTime.Value = DateTime.Now; this.dtpEndTime.Value = DateTime.Now; this.Text = "Agregar nuevo Intervalo"; this.iOriginalTimeInterval = (ScheduleEntryDTO)pNewTimeInterval; }
void IAddModifyViewForm.Modify(IDTO pTimeInterval) { if (pTimeInterval == null) { throw new EntidadNulaException("El intervalo de tiempo indicado es nulo"); //TODO excepcion argumentexception creo } else { this.iOriginalTimeInterval = (ScheduleEntryDTO)pTimeInterval; this.dtpStartTime.Value = DateTime.MinValue + iOriginalTimeInterval.StartTime; this.dtpEndTime.Value = DateTime.MinValue + iOriginalTimeInterval.EndTime; this.Text = "Modificar Intervalo"; } }
public void Validate_SaveScheduleEntryRangeParam_ActivityIdIsNull() { IBodyArchitectAccessService service = CreateServiceProxy(AddressHeader.CreateAddressHeader("APIKey", "", "EB17BC2A-94FD-4E65-8751-15730F69E7F5")); var sessionData = service.Login(ClientInformation, "test_user", "pwd".ToSHA1Hash()); var param = new SaveScheduleEntryRangeParam(); param.StartDay = DateTime.UtcNow; param.EndDay = DateTime.UtcNow.AddDays(2); var dto = new ScheduleEntryDTO(); dto.StartTime = param.StartDay; dto.EndTime = dto.StartTime + TimeSpan.FromHours(1); param.Entries.Add(dto); service.SaveScheduleEntriesRange(sessionData.Token, param); }
void ScheduleEntriesCalendar_AddAppointment(object sender, RoutedEventArgs e) { if (ctrlCalendar.ReadOnly) { return; } var item = (CalendarTimeslotItem)e.OriginalSource; var entry = new ScheduleEntryDTO(); entry.StartTime = item.StartTime.ToUniversalTime(); entry.EndTime = entry.StartTime.AddHours(1); var viewModelItem = new ScheduleEntryViewModel(entry, ctrlCalendar); viewModel.Entries.Add(viewModelItem); viewModel.SelectedAppointment = viewModelItem; viewModel.EditSelected(); //if (ctrlCalendar.DisplayMode == ScheduleDisplayMode.Room) //{ // entry.RoomId = Identifier; //} //else //{ // entry.EmployeeId = Identifier; //} //EditDomainObjectView dlg = new EditDomainObjectView(); //var ctrl = new ScheduleEntryEditorView(); //dlg.SetControl(ctrl); //ctrl.Fill(entry, ctrlCalendar.DisplayMode); //if (dlg.ShowDialog() == true) //{ // ServiceManager.Default.SaveScheduleEntry(entry); // var usluga = DomainModelCache.Uslugi[entry.UslugaId]; // IList<Appointment> list = (IList<Appointment>)ctrlCalendar.Appointments; // Appointment app = new Appointment(); // app.Color = usluga.Color; // app.Subject = usluga.Name; // app.Tag = new ScheduleEntryViewModel(entry, ctrlCalendar); // app.StartTime = entry.StartTime; // app.EndTime = entry.EndTime; // list.Add(app); // ctrlCalendar.RefreshAppointments(); //} }
public void DeleteScheduleEntry(ScheduleEntryDTO entry) { Log.WriteWarning("DeleteScheduleEntry:Username={0},entryId={1}", SecurityInfo.SessionData.Profile.UserName, entry.GlobalId); if (!SecurityInfo.Licence.IsInstructor) { throw new LicenceException("This feature is allowed for Instructor account"); } using (var trans = Session.BeginSaveTransaction()) { var dbProfile = Session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId); var db = Session.Load <ScheduleEntry>(entry.GlobalId); if (db.Profile != dbProfile) { throw new CrossProfileOperationException(); } Session.Delete(db); dbProfile.DataInfo.ScheduleEntryHash = Guid.NewGuid(); trans.Commit(); } }
public ScheduleEntryDTO SaveScheduleEntry(ScheduleEntryDTO entry) { Log.WriteWarning("SaveScheduleEntry:Username={0},entryId={1}", SecurityInfo.SessionData.Profile.UserName, entry.GlobalId); ScheduleEntry db = null; if (!SecurityInfo.Licence.IsInstructor) { throw new LicenceException("This feature is allowed for Instructor account"); } using (var trans = Session.BeginSaveTransaction()) { var dbProfile = Session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId); int count = Session.QueryOver <ScheduleEntry>().Where( x => x.Profile == dbProfile && x.GlobalId != entry.GlobalId && (x.StartTime <= entry.StartTime && x.EndTime > entry.StartTime || x.StartTime < entry.EndTime && x.EndTime >= entry.EndTime)).RowCount(); if (count > 0) { throw new AlreadyOccupiedException("This user is busy at the selected time"); } if (entry.GlobalId != Constants.UnsavedGlobalId) { db = Session.Get <ScheduleEntry>(entry.GlobalId); Mapper.Map(entry, db); } else { db = entry.Map <ScheduleEntry>(); db.Profile = dbProfile; } if (entry.MyPlaceId == null) { db.MyPlace = Session.QueryOver <MyPlace>().Where(x => x.Profile == dbProfile && x.IsDefault).SingleOrDefault(); } if (db.MyPlace.Profile != dbProfile) { throw new CrossProfileOperationException("MyPlace not belong to this user"); } db.Activity = Session.Get <Activity>(entry.ActivityId); if (entry.CustomerGroupId.HasValue) { db.CustomerGroup = Session.Get <CustomerGroup>(entry.CustomerGroupId); if (db.CustomerGroup.Profile != dbProfile) { throw new CrossProfileOperationException("Group not belong to this user"); } } if (db.Activity.Profile != dbProfile) { throw new CrossProfileOperationException("Activity not belong to this user"); } dbProfile.DataInfo.ScheduleEntryHash = Guid.NewGuid(); db = Session.Merge(db); trans.Commit(); } return(Mapper.Map <ScheduleEntry, ScheduleEntryDTO>(db)); }
public void Drop(ExDragEventArgs arg) { var app = (ScheduleEntryBaseViewModel)arg.DragEventArgs.Data.GetData("myFormat"); var championship = (ChampionshipItem)arg.DragEventArgs.Data.GetData("ChampionshipItem"); var activity = (ActivityDTO)arg.DragEventArgs.Data.GetData("ActivityDTO"); var group = (CustomerGroupDTO)arg.DragEventArgs.Data.GetData("CustomerGroupDTO"); var myPlace = (MyPlaceLightDTO)arg.DragEventArgs.Data.GetData("MyPlaceDTO"); CalendarTimeslotItem emptySlot = arg.DirectTarget as CalendarTimeslotItem; if (emptySlot == null) { return; } ScheduleEntryBaseDTO baseDTO; if (activity != null) { var dto = new ScheduleEntryDTO(); dto.ActivityId = activity.GlobalId; dto.MaxPersons = activity.MaxPersons; dto.Price = activity.Price; dto.StartTime = emptySlot.StartTime.ToUniversalTime(); dto.EndTime = dto.StartTime + activity.Duration; app = createAppointment(dto); baseDTO = dto; } else if (championship != null) { var dto = new ScheduleChampionshipDTO(); dto.StartTime = emptySlot.StartTime.ToUniversalTime(); dto.ChampionshipType = championship.Value; dto.Name = InstructorHelper.Translate(dto.ChampionshipType); dto.EndTime = dto.StartTime + TimeSpan.FromHours(4); app = createAppointment(dto); } else if (group != null) { var dto = new ScheduleEntryDTO(); dto.MaxPersons = group.MaxPersons; dto.StartTime = emptySlot.StartTime.ToUniversalTime(); dto.EndTime = dto.StartTime + TimeSpan.FromHours(1);//default entry length is one hour if (group.DefaultActivityId.HasValue) { activity = ActivitiesReposidory.Instance.GetItem(group.DefaultActivityId.Value); dto.MaxPersons = activity.MaxPersons; dto.ActivityId = activity.GlobalId; dto.Price = activity.Price; dto.EndTime = dto.StartTime + activity.Duration; } dto.CustomerGroupId = group.GlobalId; app = createAppointment(dto); baseDTO = dto; } else if (myPlace != null) { var dto = new ScheduleEntryDTO(); dto.MyPlaceId = myPlace.GlobalId; dto.StartTime = emptySlot.StartTime.ToUniversalTime(); dto.EndTime = dto.StartTime + TimeSpan.FromHours(1);//default entry length is one hour app = createAppointment(dto); baseDTO = dto; } if ((arg.DragEventArgs.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey) { app = app.Clone(true); baseDTO = app.Item; baseDTO.Version = 0; } TimeSpan diff = app.RealEndTime - app.StartTime; app.Item.StartTime = emptySlot.StartTime.ToUniversalTime(); app.Item.EndTime = (app.StartTime + diff).ToUniversalTime(); if (Entries.IndexOf(app) == -1) { Entries.Add(app); } IsModified = true; }
public InstructorEntryObjectBuilder(ScheduleEntryReservationDTO reservation, ScheduleEntryDTO scheduleEntry) { this.reservation = reservation; this.scheduleEntry = scheduleEntry; }
public async Task <ActionResult <ScheduleEntryDetailedDTO> > PostScheduleEntries(ScheduleEntryDTO scheduleEntryDTO) { var scheduleEntry = _mapper.Map <ScheduleEntry>(scheduleEntryDTO); scheduleEntry = await _scheduleEntryService.Create(scheduleEntry); if (scheduleEntry == null) { return(NotFound()); } return(_mapper.Map <ScheduleEntryDetailedDTO>(scheduleEntry)); }
public async Task <ActionResult <ScheduleEntryDetailedDTO> > UpdateScheduleEntry(int id, ScheduleEntryDTO scheduleEntryDTO) { var scheduleEntry = _mapper.Map <ScheduleEntry>(scheduleEntryDTO); if (scheduleEntry.ScheduleEntriesId != id) { return(BadRequest()); } if (!_context.ScheduleEntries.Where(x => x.ScheduleEntriesId == scheduleEntry.ScheduleEntriesId).Any()) { await _scheduleEntryService.Create(scheduleEntry); return(_mapper.Map <ScheduleEntryDetailedDTO>(scheduleEntry)); } scheduleEntry = await _scheduleEntryService.Update(scheduleEntry); if (scheduleEntry == null) { return(NotFound()); } return(_mapper.Map <ScheduleEntryDetailedDTO>(scheduleEntry)); }