Beispiel #1
0
        private async Task UpdateService()
        {
            if (ValidateInputs())
            {
                ServiceEditVM serviceEditVM = new ServiceEditVM()
                {
                    Id    = service.Id,
                    Name  = TbName.Text,
                    Price = decimal.Parse(TbPrice.Text)
                };

                ls.LblLoading.Text = "Editing";
                ls.Show();
                bool success = await serviceApi.UpdateService(serviceEditVM);

                ls.Close();

                if (success)
                {
                    Close();
                }
                else
                {
                    MessageBox.Show("Fail!");
                }
            }
            else
            {
                MessageBox.Show("All input fields are required and price must be a number!");
            }
        }
        public bool EditService(ServiceEditVM serviceEditVM)
        {
            Service service = unitOfWork.Services.Get(serviceEditVM.Id);

            service.Name  = serviceEditVM.Name;
            service.Price = serviceEditVM.Price;

            int success = unitOfWork.Complete();

            return(success > 0);
        }
 internal void SaveService(ServiceEditVM model)
 {
     if (model.ID.HasValue)
     {
         saveServiceExisting(model);
     }
     else
     {
         saveServiceNew(model);
     }
 }
        private void saveServiceExisting(ServiceEditVM model)
        {
            var inssvc = _context.InsuranceServices.Find(model.ID.Value);

            inssvc.DefectiveDate  = model.DefectiveDate;
            inssvc.EffectiveDate  = model.EffectiveDate;
            inssvc.InsuranceID    = model.InsuranceID;
            inssvc.ProviderTypeID = model.ProviderTypeID;
            inssvc.ServiceID      = model.ServiceID;

            _context.SaveChanges();
        }
        private void saveServiceNew(ServiceEditVM model)
        {
            var inssvc = new Domain2.Insurances.InsuranceService();

            inssvc.DefectiveDate  = model.DefectiveDate;
            inssvc.EffectiveDate  = model.EffectiveDate;
            inssvc.InsuranceID    = model.InsuranceID;
            inssvc.ProviderTypeID = model.ProviderTypeID;
            inssvc.ServiceID      = model.ServiceID;

            _context.InsuranceServices.Add(inssvc);
            _context.SaveChanges();
        }
Beispiel #6
0
        public ActionResult ServiceEditItem(int?insuranceServiceID)
        {
            var model = new ServiceEditVM();

            if (insuranceServiceID.HasValue)
            {
                model = _service.GetServiceEditVM(insuranceServiceID.Value);
            }

            model.ProviderTypesList = Helpers.CommonListItems.GetProviderTypes();
            model.ServicesList      = Helpers.CommonListItems.GetServices();

            return(PartialView("ServicesEdit", model));
        }
Beispiel #7
0
        public async Task <bool> UpdateService(ServiceEditVM serviceEditVM)
        {
            StringContent       content  = GetStringContent(serviceEditVM);
            HttpClient          request  = new HttpClient();
            HttpResponseMessage response = await request.PutAsync($"{ API_URL }/EditService", content);

            if (response.IsSuccessStatusCode)
            {
                bool result = await response.Content.ReadAsAsync <bool>();

                return(result);
            }
            return(false);
        }
        internal ServiceEditVM GetServiceEditVM(int insuranceServiceID)
        {
            var insuranceService = _context.InsuranceServices.Find(insuranceServiceID);

            var item = new ServiceEditVM();

            item.ID             = insuranceServiceID;
            item.ServiceID      = insuranceService.ServiceID;
            item.InsuranceID    = insuranceService.InsuranceID;
            item.ProviderTypeID = insuranceService.ProviderTypeID;
            item.EffectiveDate  = insuranceService.EffectiveDate;
            item.DefectiveDate  = insuranceService.DefectiveDate;

            return(item);
        }
Beispiel #9
0
 public ActionResult ServiceEdit(ServiceEditVM model)
 {
     _service.SaveService(model);
     return(Content("ok"));
 }