public async Task <IActionResult> Add() { List <Model> models = await _models.GetModelsAsync(); AddDroneViewModel model = new AddDroneViewModel(); model.SetModels(models); return(View(model)); }
public async Task <IActionResult> Add(AddDroneViewModel droneModel) { if (ModelState.IsValid) { Drone drone = await _drones.AddDroneAsync(droneModel.Name, droneModel.SerialNumber, droneModel.ModelId); ModelState.Clear(); droneModel.Clear(); droneModel.Message = $"Drone '{drone.Name}' added successfully"; } List <Model> models = await _models.GetModelsAsync(); droneModel.SetModels(models); return(View(droneModel)); }