public IActionResult EditRoom(CrudRoomViewModel model) { if (!ModelState.IsValid) { return(View(model)); } bool roomExists = AdminService.ExistsRoom(model.ID); if (!roomExists) { return(NotFound()); } AdminService.EditRoom(model.ID, model.Number, model.TypeID); return(RedirectToAction(nameof(AllRooms))); }
public IActionResult CreateRoom(CrudRoomViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var room = AdminService.CreateRoom(model.Number, model.TypeID); // //Directory.CreateDirectory(@"wwwroot\images\Rooms\" + room.ID); // // //var ext = Path.GetExtension(model.UploadFile.FileName); //var guid = Guid.NewGuid().ToString(); //var filePath = String.Format(@"wwwroot\images\Rooms\{0}\{1}{2}", room.ID, guid, ext); //using (var fileStream = new FileStream(filePath, FileMode.Create)) //{ // await model.UploadFile.CopyToAsync(fileStream); //} return(RedirectToAction(nameof(AllRooms))); }