public int AddMedicine(Medicine request) { if (string.IsNullOrWhiteSpace(request.FullName)) { throw new InvalidOperationException("Medicine Full name is a required field."); } if (string.IsNullOrWhiteSpace(request.Brand)) { throw new InvalidOperationException("Medicine Brand is a required field."); } if (request.ExpiryDate <= DateTime.Today.AddDays(15)) { throw new InvalidOperationException("Medicines with expiry date of 15 days or less can not be added."); } if (request.Quantity <= 0) { throw new InvalidOperationException("Medicines with quantity less than zero can not be added"); } if (request.Price < 0) { throw new InvalidOperationException("Medicine price should be non-negative number."); } request.Id = m_MedicineRepository.GetMaxId() + 1; m_MedicineRepository.AddMedicine(request); return(request.Id); }