public void Edit(BatchMedicine batchMedicine)
        {
            var currentBatchMedicine = this.GetById(batchMedicine.Id);

            currentBatchMedicine.MedicineId = batchMedicine.MedicineId;
            currentBatchMedicine.StartDate = batchMedicine.StartDate;
            currentBatchMedicine.EndDate = batchMedicine.EndDate;
            currentBatchMedicine.Observation = batchMedicine.Observation;

            Uow.BatchMedicines.Edit(currentBatchMedicine);
            Uow.Commit();
        }
 private void OnBatchMedicineCreated(BatchMedicine batchMedicine)
 {
     if (BatchMedicineCreated != null)
     {
         BatchMedicineCreated(this, batchMedicine);
     }
 }
        private void FrmCreateEditBatchMedicine_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);

                dtpStartDate.Value = _batch.DateOfBirth;
                dtpEndDate.Value = _batch.DateOfBirth.AddDays(_batch.GeneticLine.ProductionWeeks * 7);
                txtObservation.Text = "";
                formTitle = string.Format("Lote {0} - Crear Medicamento", _batch.Number.ToString());
            }

            using (var medicineService = _serviceFactory.Create<IMedicineService>())
            {
                var vaccines = medicineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlMedicines.ValueMember = "Id";
                ddlMedicines.DisplayMember = "Name";
                Medicine item = new Medicine();
                item.Name = "Selecciona un medicamento..";
                item.Id = Guid.Empty;
                vaccines.Insert(0,item);
                ddlMedicines.DataSource = vaccines;
            }

            if (_batchMedicineId != Guid.Empty)
            {
                //Editar
                using (var batchMedicineService = _serviceFactory.Create<IBatchMedicineService>())
                {
                    _batchMedicine = batchMedicineService.GetById(_batchMedicineId);
                    txtObservation.Text = _batchMedicine.Observation;
                    dtpStartDate.Value = _batchMedicine.StartDate;
                    if (_batchMedicine.EndDate != null) dtpEndDate.Value = _batchMedicine.EndDate.Value;
                    ddlMedicines.SelectedValue = _batchMedicine.MedicineId;
                    formTitle = string.Format("Lote {0} - Editar Medicamento", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }
 public BatchMedicine ToBatchMedicine()
 {
     var batchVaccine = new BatchMedicine
     {
         Id = Guid.NewGuid(),
         CreatedDate = DateTime.Now,
         BatchId = this.BatchId.GetValueOrDefault(),
         MedicineId = this.MedicineId.GetValueOrDefault(),
         StartDate = this.StartDate,
         EndDate = this.EndDate.Value,
         Observation = this.Observation,
         IsDeleted = false
     };
     return batchVaccine;
 }
 public static CreateBatchMedicineModel FromClient(BatchMedicine batchMedicine)
 {
     var form = Mapper.Map<BatchMedicine, CreateBatchMedicineModel>(batchMedicine);
     return form;
 }
 public void Create(BatchMedicine batchMedicine)
 {
     Uow.BatchMedicines.Add(batchMedicine);
     Uow.Commit();
 }