void IAddModifyViewForm.Add(IDTO pNewDateInterval)
 {
     this.txtTitle.Text = String.Empty;
     this.dtpStartDate.Value = DateTime.Now;
     this.dtpEndDate.Value = DateTime.Now;
     this.Text = "Agregar nuevo Intervalo";
     this.iOriginalDateInterval = (ScheduleDTO)pNewDateInterval;
 }
        public ScheduleDTO GetSchedule(int pId)
        {
            ScheduleDTO lResult = new ScheduleDTO();
            Schedule lTemp;

                lTemp = serv.Read(pId);
                //lResult = MapperHelper.Map<Schedule, ScheduleDTO>(lTemp, lResult);
                lResult = Mapper.Map<Schedule, ScheduleDTO>(lTemp);

          //  lResult = MapperHelper.Map<Schedule,ScheduleDTO>(lTemp,lResult);
            return lResult;
        }
        void AssertAreEqualForAdding(ScheduleDTO lDto, ScheduleDTO lResult)
        {
            BaseAssertAreEqual(lDto, lResult);

            int i = 0; int j = 0;
            while ((i < lDto.ActiveHours.Count) && (j < lResult.ActiveHours.Count))
            {
                Assert.AreEqual(lDto.ActiveHours[i].StartTime, lResult.ActiveHours[j].StartTime);
                Assert.AreEqual(lDto.ActiveHours[i].EndTime, lResult.ActiveHours[j].EndTime);
                i++; j++;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                this.dateInterval = new ScheduleDTO();
                AgregarModificarIntervaloFecha ventana = new AgregarModificarIntervaloFecha();
                this.dgvDateInterval.Add(ventana, this.dateInterval);
                iController.AddSchedule(this.dateInterval);
                this.CargarDateDataGrid();
            }
            catch (Exception)
            {

                throw;
            }
        }
Exemplo n.º 5
0
 public void View(ScheduleDTO pDateInterval)
 {
     if (pDateInterval == null)
     {
         throw new EntidadNulaException("El Intervalo de fechas indicado es nulo");
         //TODO excepcion argumentexception creo
     }
     else
     {
         this.txtTitle.Text = pDateInterval.Name;
         this.dtpStartDate.Value = pDateInterval.ActiveFrom;
         this.dtpEndDate.Value = pDateInterval.ActiveUntil;
         this.Text = "Intervalo de fechas: " + pDateInterval.Name;
         foreach (Days dia in pDateInterval.Days)
         {
             switch (dia)
             {
                 case Days.Domingo:
                     this.lblDays.Text += Days.Domingo.ToString()+" - ";
                     break;
                 case Days.Lunes:
                     this.lblDays.Text += Days.Lunes.ToString()+ " - ";
                     break;
                 case Days.Martes:
                     this.lblDays.Text += Days.Martes.ToString()+ " - ";
                     break;
                 case Days.Miercoles:
                     this.lblDays.Text += Days.Miercoles.ToString()+ " - ";
                     break;
                 case Days.Jueves:
                     this.lblDays.Text += Days.Jueves.ToString()+ " - ";
                     break;
                 case Days.Viernes:
                     this.lblDays.Text += Days.Viernes.ToString()+ " - ";
                     break;
                 case Days.Sabado:
                     this.lblDays.Text += Days.Sabado.ToString()+ " - ";
                     break;
                 default:
                     break;
             }
         }
         this.dgvTimeInterval.SetSource(pDateInterval.ActiveHours);
         this.ShowDialog();
     }
 }
        void BaseAssertAreEqual(ScheduleDTO lDto, ScheduleDTO lResult)
        {
            Assert.AreEqual(lDto.Id, lResult.Id);
            Assert.AreEqual(lDto.Name, lResult.Name);
            Assert.AreEqual(lDto.ActiveFrom, lResult.ActiveFrom);
            Assert.AreEqual(lDto.ActiveUntil, lResult.ActiveUntil);

            Assert.AreEqual(lDto.Days.Count, lResult.Days.Count);
            Assert.AreEqual(lDto.ActiveHours.Count, lResult.ActiveHours.Count);

            int i = 0; int j = 0;
            while ((i < lDto.Days.Count) && (j < lResult.Days.Count))
            {
                Assert.AreEqual(lDto.Days[i], lResult.Days[j]);
                i++; j++;
            }
        }
 void IAddModifyViewForm.Modify(IDTO pDateInterval)
 {
     if (pDateInterval == null)
     {
         throw new EntidadNulaException("El intervalo de fechas indicado es nulo");
         //TODO excepcion argumentexception creo
     }
     else
     {
         this.iOriginalDateInterval = (ScheduleDTO)pDateInterval;
         this.txtTitle.Text = iOriginalDateInterval.Name;
         this.dtpStartDate.Value = iOriginalDateInterval.ActiveFrom;
         this.dtpEndDate.Value = iOriginalDateInterval.ActiveUntil;
         this.Text = "Modificar Intervalo";
         foreach (Days dia in iOriginalDateInterval.Days)
         {
             switch (dia)
             {
                 case Days.Domingo:
                     this.chkSunday.Checked = true;
                     break;
                 case Days.Lunes:
                     this.chkMonday.Checked = true;
                     break;
                 case Days.Martes:
                     this.chkTuesday.Checked = true;
                     break;
                 case Days.Miercoles:
                     this.chkWednesday.Checked = true;
                     break;
                 case Days.Jueves:
                     this.chkThursday.Checked = true;
                     break;
                 case Days.Viernes:
                     this.chkFriday.Checked = true;
                     break;
                 case Days.Sabado:
                     this.chkSaturday.Checked = true;
                     break;
                 default:
                     break;
             }
         }
     }
 }
 public void DeleteSchedule(ScheduleDTO pDto)
 {
         serv.Delete(pDto.Id);
 }
 public int ModifySchedule(ScheduleDTO pDto)
 {
         Schedule lSchedule = Mapper.Map<ScheduleDTO, Schedule>(pDto);
         serv.Update(lSchedule);
         return lSchedule.Id;
 }
 public int AddSchedule(ScheduleDTO pDto)
 {
         Schedule lSchedule = Mapper.Map<ScheduleDTO, Schedule>(pDto);
         serv.Create(lSchedule);
         return lSchedule.Id;
 }
        private void dgvDateInterval_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow row = dgvDateInterval.CurrentRow;
                this.dateInterval = dgvDateInterval.GetItem(row.Index);
                AgregarModificarIntervaloFecha ventana = new AgregarModificarIntervaloFecha();
                this.dgvDateInterval.Modify(ventana, this.dateInterval);
                iController.ModifySchedule(this.dateInterval);
            }
            catch (Exception)
            {

                throw;
            }

        }
 private void btnView_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow row = dgvDateInterval.CurrentRow;
         this.dateInterval = dgvDateInterval.GetItem(row.Index);
         DateIntervalView ventana = new DateIntervalView();
         ventana.View(this.dateInterval);
     }
     catch (EntidadNulaException ex)
     {
         MessageBox.Show(ex.Message, "Entidad nula", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnAddTimeInterval_Click_1(object sender, EventArgs e)
 {
     DataGridViewRow row = dgvDateInterval.CurrentRow;
     this.dateInterval = dgvDateInterval.GetItem(row.Index);
     this.timeInterval = new ScheduleEntryDTO();
     IAddModifyViewForm ventana = new AgregarModificarIntervaloTiempo();
     ventana.Add((IDTO)this.timeInterval);
     DialogResult resultado = ventana.ShowForm();
     if (resultado == DialogResult.OK)
     {
         this.dateInterval.ActiveHours.Add(this.timeInterval);
     }
     //TODO revisar esto
 }
 //TODO estos dos metodos son muy similares. No podes por ej cuando se carga todo setear el dgvDate en index 0 cosa de que se dispare auto el segundo metodo?
 private void dgvDateInterval_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     DataGridViewRow row = dgvDateInterval.CurrentRow;
     this.dateInterval = dgvDateInterval.GetItem(row.Index);
     this.dgvTimeInterval.SetSource(this.dateInterval.ActiveHours);
     //TODO Martin: porque es que se usa un campo date interval?, osea, se usa esa misma instancia en varios metodos como para justificarlo?
 }
 private void CargarTimeDataGrid()
 {
     this.dateInterval = dgvDateInterval.GetItem(0);
     this.dgvTimeInterval.SetSource(this.dateInterval.ActiveHours);
 }
        public void DateIntervalController_NewInterval()
        {
            // Arrange
            string lNewName = "Crece desde el pie";
            DateTime lNewActiveFrom = new DateTime(2016, 02, 01);
            DateTime lNewActiveUntil = new DateTime(2016, 02, 29);
            TimeSpan lNewStartTime = new TimeSpan(08, 0, 0);
            TimeSpan lNewEndTime = new TimeSpan(10, 0, 0);

            ManageScheduleHandler lController = new ManageScheduleHandler();
            ScheduleDTO lResult;
            ScheduleDTO lDto;


            // Act
            lDto = new ScheduleDTO()
            {
                Name = lNewName,
                ActiveUntil = lNewActiveUntil,
                ActiveFrom = lNewActiveFrom,
                Days = new List<Days>()
                {
                    Days.Lunes,
                    Days.Miercoles,
                    Days.Viernes,
                },
                ActiveHours = new List<ScheduleEntryDTO>()
                {
                    new ScheduleEntryDTO()
                    {
                        EndTime = lNewEndTime,
                        StartTime = lNewStartTime
                    }
                }
            };

            lDto.Id = lController.AddSchedule(lDto);

            // Assert
            lResult = lController.GetSchedule(lDto.Id);
            AssertAreEqualForAdding(lDto, lResult);

        }