Exemple #1
0
        public async Task <IActionResult> Create(ServiceLineViewModel serviceLineViewModel)
        {
            if (ModelState.IsValid)
            {
                var serviceLineModel = new ServiceLineModel
                {
                    ForeignKey2_      = serviceLineViewModel.ServiceLineModel.ForeignKey2_,
                    ForeignKey1_      = serviceLineViewModel.ServiceLineModel.ForeignKey1_,
                    ForeignKey3_      = serviceLineViewModel.ServiceLineModel.ForeignKey3_,
                    Added_Quantity    = serviceLineViewModel.ServiceLineModel.Added_Quantity,
                    Used_Quantity     = serviceLineViewModel.ServiceLineModel.Used_Quantity,
                    Resource_Quantity = serviceLineViewModel.ServiceLineModel.Resource_Quantity
                };

                var serviceID =
                    _context.ServiceModel.Find(serviceLineViewModel.ServiceLineModel.ForeignKey2_.Service_ID);
                var resID   = _context.ResourceModel.Find(serviceLineViewModel.ServiceLineModel.ForeignKey1_.Res_ID);
                var offerID = _context.OfferModel.Find(serviceLineViewModel.ServiceLineModel.ForeignKey3_.Offer_ID);
                serviceLineModel.ForeignKey2_ = serviceID;
                serviceLineModel.ForeignKey1_ = resID;
                serviceLineModel.ForeignKey3_ = offerID;

                ServiceLine_APIController api = new ServiceLine_APIController(_context);
                await api.PostEmployeeOfferModel(serviceLineModel);

                return(RedirectToAction("Create"));
            }

            return(RedirectToAction("Create"));
        }
Exemple #2
0
        //Nichlas
        // GET: ServiceLine
        public async Task <IActionResult> Index()
        {
            var serviceLineModels    = _context.ServiceLineModel.ToList();
            var serviceModel         = _context.ServiceModel.ToList();
            var resourceModel        = _context.ResourceModel.ToList();
            var offerModel           = _context.OfferModel.ToList();
            var employeeOffersModels = _context.EmployeeOfferModel.ToList();

            var viewModel = new ServiceLineViewModel
            {
                ServiceLineModels   = serviceLineModels,
                OfferModel          = offerModel,
                ServiceModel        = serviceModel,
                ResourceModel       = resourceModel,
                EmployeeOfferModels = employeeOffersModels
            };

            return(View(viewModel));
        }