コード例 #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"));
        }
コード例 #2
0
        public async Task <IActionResult> ReportDetails(int[] resArray, int[] hoursArray)
        {
            ServiceLine_APIController   ServiceLine_API   = new ServiceLine_APIController(_context);
            EmployeeOffer_APIController employeeOffer_Api = new EmployeeOffer_APIController(_context);

            for (int i = 0; i < resArray.Length; i = i + 2)
            {
                var data = await _context.ServiceLineModel.FirstOrDefaultAsync(m => m.Service_Line_ID == resArray[i]);

                data.Used_Quantity = data.Used_Quantity + resArray[i + 1];
                await ServiceLine_API.PutServiceLineModel(resArray[i], data);
            }

            for (int i = 0; i < hoursArray.Length; i = i + 2)
            {
                var data = await _context.EmployeeOfferModel.FirstOrDefaultAsync(m => m.EmployeeOffer_ID == hoursArray[i]);

                data.HoursWorked = data.HoursWorked + hoursArray[i + 1];
                await employeeOffer_Api.PutEmployeeOfferModel(hoursArray[i], data);
            }

            return(Accepted());
        }