Esempio n. 1
0
        public async Task <DeleteMedicineResponse> DeleteMedicineAsync(DeleteMedicineRequest request)
        {
            var            response = new DeleteMedicineResponse();
            MedicineEntity entity   = await _medicineRepository.GetMedicineById(request.MedicineId);

            if (entity == null)
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return(response);
            }

            bool status = await _medicineRepository.DeleteMedicineAsync(entity);

            if (status)
            {
                response.StatusCode = (int)HttpStatusCode.OK;
            }
            else
            {
                response.StatusCode = (int)HttpStatusCode.BadRequest;
                _logger.LogWarning(""); //TODO - LOGGING
            }

            return(response);
        }
Esempio n. 2
0
        public async Task <MedicineDomain> GetMedicineById(int medicineId)
        {
            var medicine = await _medicineRepository.GetMedicineById(medicineId);

            var medicineDomain = _mapper.Map <MedicineDomain>(medicine);

            return(medicineDomain);
        }
Esempio n. 3
0
        public ActionResult Edit(string id)
        {
            var intId = 0;

            int.TryParse(id, out intId);
            Medicine medicine = null;

            try
            {
                medicine = medicineRepository.GetMedicineById(intId);
                if (medicine == null)
                {
                    return(RedirectToAction("Error404", "Error"));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }

            IMedicineTypeRepository    objMedicineType     = new MedicineTypeRepository();
            IMedicineUnitRepository    objMedicineUnit     = new MedicineUnitRepository();
            IEnumerable <MedicineType> medicineTypeRecords = null;
            IEnumerable <MedicineUnit> unitRecords         = null;

            try {
                medicineTypeRecords = objMedicineType.Get();
                unitRecords         = objMedicineUnit.Get();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            medicineModel = new MedicineModels
            {
                medicine            = medicine,
                medicineTypeRecords = medicineTypeRecords,
                unitRecords         = unitRecords
            };
            return(View(medicineModel));
        }
Esempio n. 4
0
        private MedicineAssignedVM GetMedicineViewModel(prescription prescriptionItem)
        {
            medicine med = _medicineRepository.GetMedicineById(prescriptionItem.medicine_id);

            return(new MedicineAssignedVM()
            {
                Name = med.medicine_name,
                Description = prescriptionItem.description,
                Quantity = prescriptionItem.quantity_indicated.ToString(),
                SalePrice = med.sale_price_per_unit.ToString(),
                Unit = med.sale_unit
            });
        }
Esempio n. 5
0
        public void Display(int idSelected)
        {
            var medicineFromDB = _repository.GetMedicineById(idSelected);

            if (medicineFromDB != null)
            {
                _view.TxtMedicineName  = medicineFromDB.medicine_name;
                _view.TxtEntryQuantity = medicineFromDB.quantity_in_entry_unit.ToString();
                _view.TxtEntryUnit     = medicineFromDB.entry_unit;
                _view.TxtEntryPrice    = medicineFromDB.entry_price.ToString();
                _view.TxtExpiryDay     = String.Format("{0:dd/MM/yyyy}", medicineFromDB.expiry_day);
                _view.TxtSaleUnit      = medicineFromDB.sale_unit;
                _view.TxtSalePrice     = medicineFromDB.sale_price_per_unit.ToString();
                _view.TxtExchangeRatio = medicineFromDB.unit_exchange_ratio.ToString();
            }
        }
Esempio n. 6
0
 public async Task <Medicine> GetMedicineById(int id)
 {
     return(await medicineRepository.GetMedicineById(id));
 }
Esempio n. 7
0
 public Medicine GetMedicineById(int id)
 {
     return(_repository.GetMedicineById(id));
 }
 public Medicine GetMedicineById(long id)
 {
     return(medicineRepository.GetMedicineById(id));
 }
 /// <summary>
 /// get medicine by id
 /// </summary>
 /// <returns></returns>
 private async Task <Medicine> GetMedicineById(Guid?id)
 {
     return(await _medicineRepository.GetMedicineById(id));
 }