Пример #1
0
        public async Task <IActionResult> Create(EmployeeOfferViewModel employeeOfferViewModel)
        {
            if (ModelState.IsValid)
            {
                var employeeOfferModel = new EmployeeOfferModel
                {
                    HoursWorked  = employeeOfferViewModel.EmployeeOfferModel.HoursWorked,
                    ForeignKey1_ = employeeOfferViewModel.EmployeeOfferModel.ForeignKey1_,
                    ForeignKey2_ = employeeOfferViewModel.EmployeeOfferModel.ForeignKey2_,
                };
                var offerID    = _context.OfferModel.Find(employeeOfferViewModel.EmployeeOfferModel.ForeignKey1_.Offer_ID);
                var EmployeeID = _context.EmployeeModel.Find(employeeOfferViewModel.EmployeeOfferModel.ForeignKey2_.Employee_ID);
                employeeOfferModel.ForeignKey1_ = offerID;
                employeeOfferModel.ForeignKey2_ = EmployeeID;

                EmployeeOffer_APIController api = new EmployeeOffer_APIController(_context);
                await api.PostEmployeeOfferModel(employeeOfferModel);
            }
            return(RedirectToAction("Create", "ServiceLine"));
        }
Пример #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());
        }