Пример #1
0
        public async Task <ActionResult> Update(UpdateMedicineRequestModel model)
        {
            var updated = await _medicineService.UpdateMedicine(model);

            if (!updated)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public async Task <ActionResult> Update(UpdateMedicineRequestModel model)
        {
            var updated = await this.medicineService.Update(
                model.Id,
                model.Name,
                model.Price,
                model.Quantity
                );

            if (!updated)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Пример #3
0
        public async Task <bool> UpdateMedicine(UpdateMedicineRequestModel updateMedicineRequestModel)
        {
            var medicine = await FetchMedicineByName(updateMedicineRequestModel.Name);

            if (medicine is null)
            {
                return(false);
            }

            medicine.Name       = updateMedicineRequestModel.Name;
            medicine.Brand      = updateMedicineRequestModel.Brand;
            medicine.ExpiryDate = updateMedicineRequestModel.ExpiryDate;
            medicine.Quantity   = updateMedicineRequestModel.Quantity;
            medicine.Price      = updateMedicineRequestModel.Price;
            medicine.Text       = updateMedicineRequestModel.Text;
            await _dbContext.SaveChangesAsync();

            return(true);
        }