Ejemplo n.º 1
0
        public void Insert(clinic_service clinic_service)
        {
            _serviceList.Add(clinic_service);
            _clinicEntities.clinic_service.Add(clinic_service);


            Save();
        }
Ejemplo n.º 2
0
        public void AddServiceToBill_NoneExistsBillId_ThrowsArgumentOutOfRangeException()
        {
            clinic_service validService = new clinic_service();

            int NoneExistsBillId = -1;

            Action act = () => _sut.AddServiceToBill(NoneExistsBillId, validService);

            act.Should().Throw <ArgumentOutOfRangeException>()
            .WithMessage("Bill Khong Ton Tai\nParameter name: billId");
        }
Ejemplo n.º 3
0
 public static ServiceVM ServiceTransform(clinic_service service)
 {
     return(new ServiceVM
     {
         Id = service.id,
         Name = service.service_name,
         Price = service.price.ToString(),
         Type = service.Type,
         MedicineUsage = service.medicine != null ? service.medicine.medicine_name : string.Empty
     });
 }
Ejemplo n.º 4
0
        private clinic_service GetServiceFromView()
        {
            clinic_service clinic_Service = new clinic_service()
            {
                service_name = _view.TxtServiceName,
                price        = long.Parse(_view.TxtPrice),
                Type         = _view.CbServiceTypes.Text,
                Medicine_Id  = _view.SelectedMedicineId,
                is_active    = true
            };

            return(clinic_Service);
        }
Ejemplo n.º 5
0
        public void DeleteService_ExistsId_DelelteServiceInDatabaseSuccessfully()
        {
            SetupDbSetForUsingFindMethod();
            int id             = 1;
            var serviceDeleted = new clinic_service();

            _stubDbContext.Setup(c => c.clinic_service.Remove(It.IsAny <clinic_service>()))
            .Callback <clinic_service>(service => serviceDeleted = service);

            _sut.Delete(id);

            _stubDbContext.Verify(c => c.clinic_service.Remove(serviceDeleted), Times.Once);
            _stubDbContext.Verify(c => c.SaveChanges());
        }
Ejemplo n.º 6
0
        public void InsertService_WithValidService_InsertToDatabaseSuccessfully()
        {
            var newService = new clinic_service()
            {
                id           = 4,
                service_name = "test",
                is_active    = true,
                price        = 10000
            };

            Action act = () => _sut.Insert(newService);

            act.Should().NotThrow();
        }
Ejemplo n.º 7
0
        public void Update(clinic_service serviceChanged)
        {
            int indexToReplace = (_serviceList).FindIndex(m => m.id == serviceChanged.id);

            _serviceList[indexToReplace] = serviceChanged;//replace this way for refresh list immediately

            var serviceFromDb = _clinicEntities.clinic_service.Find(serviceChanged.id);

            if (serviceFromDb != null)
            {
                _clinicEntities.Entry(serviceFromDb).CurrentValues.SetValues(serviceChanged);
                Save();
            }
        }
Ejemplo n.º 8
0
        public void InsertService_WithValidService_InsertToList()
        {
            var newService = new clinic_service()
            {
                id           = 4,
                service_name = "test"
                ,
                is_active = true,
                price     = 10000
            };

            _sut.Insert(newService);

            _sut.GetAll().Should().Contain(newService);
        }
Ejemplo n.º 9
0
        public void AddServiceToBill(int billId, clinic_service service)
        {
            bill bill = GetUnpaidBillById(billId);

            if (bill is null)
            {
                throw new ArgumentOutOfRangeException("billId", "Bill Khong Ton Tai");
            }

            var serviceToAdd = _clinicEntities.clinic_service.Find(service.id);



            bill.clinic_service.Add(serviceToAdd);
            Save();
        }
Ejemplo n.º 10
0
        public void AddServiceToBill_ExistsBillIdAndValidService_NotThrowsException()
        {
            clinic_service validService =
                new clinic_service()
            {
                id = 1, service_name = "Thu mau", price = 50000, is_active = true
            };

            _stubDbContext.Setup(c => c.clinic_service.Attach(validService));

            int NoneExistsBillId = 1;

            Action act = () => _sut.AddServiceToBill(NoneExistsBillId, validService);

            act.Should().NotThrow();
        }
Ejemplo n.º 11
0
        public void UpdateService_WithValidService_UpdateServiceInList()
        {
            var serviceUpdated = new clinic_service()
            {
                id           = 1,
                service_name = "test",
                is_active    = true,
                price        = 10000
            };

            _sut.Update(serviceUpdated);

            _sut.GetAll().Should()
            .Contain(serviceUpdated)
            .And
            .NotContain(_stubServiceList[0]);
        }
Ejemplo n.º 12
0
        public void Add()
        {
            var service = new clinic_service()
            {
                service_name = _view.TxtServiceName,
                price        = long.Parse(_view.TxtPrice),
                Type         = _view.CbServiceTypes.Text,
                is_active    = true
            };

            if (_view.SelectedMedicineId != null)
            {
                service.Medicine_Id = _view.SelectedMedicineId;
            }

            _repository.Insert(service);
        }
Ejemplo n.º 13
0
 private void DisplayServiceSelected(clinic_service serviceSelected)
 {
     _view.DgvServicesSelected.Rows.Add(serviceSelected.service_name, serviceSelected.price);
 }