public async Task <ActionResult <ServiceLineModel> > PostEmployeeOfferModel(ServiceLineModel serviceLineModel)
        {
            _context.ServiceLineModel.Add(serviceLineModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetServiceLineModel", new { id = serviceLineModel.Service_Line_ID }, serviceLineModel));
        }
        public async Task <IActionResult> PutServiceLineModel(int id, ServiceLineModel serviceLineModel)
        {
            if (id != serviceLineModel.Service_Line_ID)
            {
                return(BadRequest());
            }

            _context.Entry(serviceLineModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceLineModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
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"));
        }
Ejemplo n.º 4
0
 public ServiceLineViewModel(ServiceLineModel sl)
 {
     _SL = sl;
 }
Ejemplo n.º 5
0
 public ServiceLineViewModel()
 {
     _SL = new ServiceLineModel();
 }