public async Task Create(MedicineCreateModel medicineCreateModel) { Medicine med = new Medicine() { Id = new Guid(), Name = medicineCreateModel.Name, Prospect = medicineCreateModel.Prospect }; _repository.Create(med); if (medicineCreateModel.File != null) { foreach (var file in medicineCreateModel.File) { if (file.Length > 0) { string path = Path.Combine(_env.WebRootPath, "Medicines\\" + med.Id); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (var fileStream = new FileStream(Path.Combine(path, file.FileName), FileMode.Create)) { await file.CopyToAsync(fileStream); } } } } }
public async Task <Medicine> Create(Medicine medicine) { var success = await _repository.Create(medicine); if (success) { return(medicine); } else { return(null); } }
private void Med_Create_Click(object sender, EventArgs e) { try { medRepos.Create(new Medicine() { Id = int.Parse(med_Id.Text), name = med_name.Text ?? "", expirationDate = med_expirationDate.Text, amount = int.Parse(med_amount.Text), storageTemperature = int.Parse(med_storageTemperature.Text) }); MessageBox.Show("Created successfully!", "success", MessageBoxButtons.OK, MessageBoxIcon.Information); Clear_Table(this.dataGridView1); Load_Med_Table(this.dataGridView1); } catch (Exception ex) { MessageBox.Show("exception!", ex.Message, MessageBoxButtons.OK); } }
public void Add(MedicineDto medicineDto) { var medicine = new Medicine(medicineDto.Name, medicineDto.Description); _medicineRepository.Create(medicine); }
public Medicine CreateMedicine(Medicine model) { return(_medicineRepository.Create(model)); }