public async Task <IActionResult> PutElevators(long id, Elevators elevators)
        {
            if (id != elevators.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Name,Units")] PartType partType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(partType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(partType));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ID,Address")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stock);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PopulatePositionsData(stock);
            return(View(stock));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ID,PartID,StockID,ArrDate,Quantity")] Left left)
        {
            if (ModelState.IsValid)
            {
                _context.Add(left);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartID"]  = new SelectList(_context.Parts, "ID", "ID", left.PartID);
            ViewData["StockID"] = new SelectList(_context.Stocks, "ID", "ID", left.StockID);
            return(View(left));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("CustomerID,SignDate")] Contract contract)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contract);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["CustomerID"] = new SelectList(_context.Customers, "ID", "ID", contract.CustomerID);
            PopulateCustomersDropDownList();
            return(View(contract));
        }
        public async Task <IActionResult> UpdateStatus([FromRoute] long id, Batteries current)
        {
            if (id != current.Id)
            {
                return(BadRequest());
            }

            if (current.BatteryStatus == "Active" || current.BatteryStatus == "Inactive" || current.BatteryStatus == "Intervention")
            {
                _context.Entry(current).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Content("Battery: " + current.Id + ", status as been change to: " + current.BatteryStatus));
            }

            return(Content("Please insert a valid status : Intervention, Inactive, Active, Tray again !  "));
        }
        public async Task <IActionResult> UpdateStatus([FromRoute] long id, Columns mycolumn)
        {
            if (id != mycolumn.Id)
            {
                return(BadRequest());
            }

            if (mycolumn.ColumnStatus == "Active" || mycolumn.ColumnStatus == "Inactive" || mycolumn.ColumnStatus == "Intervention")
            {
                _context.Entry(mycolumn).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Content("Column: " + mycolumn.Id + ", status as been change to: " + mycolumn.ColumnStatus));
            }

            return(Content("Please insert a valid status : Intervention, Inactive, Active, Tray again !  "));
        }
        public async Task <IActionResult> UpdateElevatorStatus([FromRoute] long id, Elevators elevator)
        {
            if (id != elevator.Id)
            {
                Console.WriteLine(elevator.Id);
                return(Content("Wrong id ! please check and try again"));
            }

            if (elevator.ElevatorStatus == "Active" || elevator.ElevatorStatus == "Inactive" || elevator.ElevatorStatus == "Intervention")
            {
                _context.Entry(elevator).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Content("Elevator: " + elevator.Id + ", status as been change to: " + elevator.ElevatorStatus));
            }

            return(Content("Please insert a valid status : Intervention, Inactive, Active, Tray again !  "));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("FirstName,Surname")] Employee employee)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(employee);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Виникла помилка під час збереження даних. " + ex.Message);
            }
            return(View(employee));
        }
        public async Task <IActionResult> CompletedInterventions([FromRoute] long id, [FromRoute] string status)
        {
            // lets get our intervention before update
            var update = await _context.Interventions.FindAsync(id);

            // verify the status from the route and handle the response
            if (status == "inprogress")
            {
                // verify if the id in the route is the same in the Body
                if (update == null)
                {
                    return(Content("Wrong id or records dosen't exist ! please check and try again"));
                }
                // verify the status if is already modified
                if (update.Status == "InProgress")
                {
                    return(Content("The actual status of the intervention is already InProgress since :" + update.StartIntervention + "! "));
                }
                else if (update.Status == "Completed")
                {
                    return(Content("The actual status of the intervention is Completed ! End date (UTC):  " + update.EndIntervention));
                }
                else if (update.Status == "Pending")
                {
                    // update date and status
                    update.StartIntervention = DateTime.UtcNow;
                    update.Status            = "InProgress";
                }

                else
                {
                    // send message to help the user
                    return(Content("Please insert a valid status the request adress : inprogress and Tray again please !  "));
                }
                // update and save
                _context.Interventions.Update(update);
                await _context.SaveChangesAsync();

                // confirmation message
                return(Content("Intervention: " + update.Id + ", status has been changed to: " + update.Status));
            }
            // 2 case completed

            else if (status == "completed")
            {
                // verify if the id in the route is the same in the Body
                if (update == null)
                {
                    return(Content("Wrong id or records dosen't exist ! please check and try again"));
                }
                // verify the status if is already modified
                if (update.Status == "Completed")
                {
                    return(Content("The actual status of the intervention is already Completed ! End date:  " + update.EndIntervention));
                }
                if (update.Status == "Pending")
                {
                    return(Content("The actual intervention is not started yet: Pending ! please try inprogress to start the intervention"));
                }
                else if (update.Status == "InProgress")
                {
                    // update date and status
                    update.EndIntervention = DateTime.UtcNow;
                    update.Status          = "Completed";
                }

                else
                {
                    // send message to help the user
                    return(Content("Please insert a valid status the request adress : completed and Tray again please !  "));
                }
                // update and save
                _context.Interventions.Update(update);
                await _context.SaveChangesAsync();

                // confirmation message
                return(Content("Intervention: " + update.Id + ", status has been changed to: " + update.Status));
            }

            // help the user to specify the endpoints
            else
            {
                return(Content("hem hem .. something wrong! please use this route format: [api/Intervention/{id}/inprogress] or  [api/Intervention/{id}/completed]"));
            }
        }