public ViewResult AddServiceToRepostory(string Plane, string Mechanic, string Date, string Name, string Nickname) { Service service = new Service(); service.Data = Date; service.By = Mechanic; service.Samolot = Plane; service.Id = 0; servicesRepository.AddService(service); List <string> output = new List <string>(); foreach (var user in userRepository.Users) { if (user.Role == "Mechanic") { output.Add(user.Name); } } SelectList List = new SelectList(output); List <string> output1 = new List <string>(); foreach (var plane in repository.Samoloty) { output1.Add(plane.Nazwa); } SelectList PlaneList = new SelectList(output1); PlaneListViewModel viewModel = new PlaneListViewModel() { Name = Name, NickName = Nickname, ListaSamolotów = PlaneList, MechanicList = List }; TempData["addmanuallyservice"] = "Dodano servis , dnia " + Date + " , mechanikowi " + Mechanic.Replace("_", " ") + " , dla samolotu " + Plane.Replace("_", " ") + "."; return(View("AddManuallyService", viewModel)); }
public async Task <IActionResult> AddService(Service service) { string role = Helper.GetRole(Request.Headers["Authorization"]); if (role != "company") { return(BadRequest("Only company accounts can 'delete' services")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _repo.AddService(service); if (result) { return(StatusCode(201)); } return(StatusCode(500)); }
public ActionResult RezerwacjaNaNaprawe(string PlaneName, string Date, string WhyIsServiced, string Name, string NickName) { Service dbEntry = new Service(); dbEntry.Samolot = PlaneName; dbEntry.Data = Date; dbEntry.By = Name; dbEntry.Id = 0; dbEntry.WhyIsServiced = WhyIsServiced; List <string> output = new List <string>(); foreach (var samolot in repository.Samoloty) { output.Add(samolot.Nazwa); } SelectList Lista = new SelectList(output); PlaneListViewModel planeListViewModel = new PlaneListViewModel { Name = Name, NickName = NickName, Samoloty = repository.Samoloty, ListaSamolotów = Lista, Serwis = repository1.Services }; if (DateTime.ParseExact(Date, "dd.MM.yyyy", CultureInfo.InvariantCulture) < DateTime.Today) { TempData["mechanicmessage"] = "Nie można dodać rezerwacji serwisu , starszej od dnia dzisiejszego!"; return(View("AddServiceToPlane", planeListViewModel)); } else { repository1.AddService(dbEntry); TempData["mechanicmessage"] = "Dodano rezerwacje terminu na servis samolotu " + PlaneName + " , w dniu " + Date; return(View("AddServiceToPlane", planeListViewModel)); } }