public async Task <IActionResult> Create([Bind("WorkOrderID,WorkOrderType,PropertyInfo,SchedulingManager,TechInfo,CurrentStatus,ProposedDate,ScheduledDate")] WorkOrder workOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workOrder));
        }
        public async Task <LocationDto> AddLocation(string description)
        {
            var location = new Location()
            {
                LocationDescription = description
            };

            _context.Location.Add(location);
            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(_mapper.Map <LocationDto>(location));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,WorkOrderID,ColumnChanged,OldValue,NewValue,Timestamp")] WorkOrderHistory workOrderHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workOrderHistory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorkOrderID"] = new SelectList(_context.WorkOrders, "WorkOrderID", "WorkOrderID", workOrderHistory.WorkOrderID);
            return(View(workOrderHistory));
        }
        public async Task <TechnicianDto> AddTechnician(string firstName, string lastName)
        {
            var tech = new Technician()
            {
                FirstName = firstName,
                LastName  = lastName
            };

            _context.Technicians.Add(tech);
            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(_mapper.Map <TechnicianDto>(tech));
        }
        public async Task <SingleCar> AddOrUpdateCarAsync(SingleCar car)
        {
            if (car.Id is null)
            {
                return(await AddCarAsync(car).ConfigureAwait(false));
            }

            var result = await _context.Cars.SingleOrDefaultAsync(c => c.Id == car.Id.Value).ConfigureAwait(false);

            if (result is null)
            {
                return(await AddCarAsync(car).ConfigureAwait(false));
            }

            var updatedCar = _mapper.Map <Car>(car);

            _context.Cars.Attach(updatedCar);
            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(car);
        }
示例#6
0
        public async Task AddWorkOrder(SingleWorkOrder workOrder)
        {
            var tech = await _context.Technicians.SingleOrDefaultAsync(t => t.Id == workOrder.Technician.Id);

            var wo = _mapper.Map <WorkOrder>(workOrder);

            if (workOrder.Location != null)
            {
                wo.Location = await _context.Location.SingleOrDefaultAsync(l => l.Id == workOrder.Location.Id);
            }

            wo.Technician = tech;
            wo.UserAdded  = await GetUser().ConfigureAwait(false);

            wo.DateAdded   = DateTime.UtcNow;
            wo.LastUpdated = DateTime.UtcNow;
            wo.Photos      = await _photoService.UploadPictures(workOrder.Pictures).ConfigureAwait(false);

            _context.WorkOrders.Add(wo);
            await _context.SaveChangesAsync().ConfigureAwait(false);
        }