public RoomReservationViewModel() { RoomReservation_SponsorViewModel = new RoomReservation_SponsorViewModel(); //default 1 RoomReservation_RoomDetailsViewDetail; RoomReservation_RoomDetailsViewDetailList = new List<RoomReservation_RoomDetailsViewDetail>(); RoomReservation_RoomDetailsViewDetail room_detailviewmodel= new RoomReservation_RoomDetailsViewDetail(); RoomReservation_RoomDetailsViewDetailList.Add(room_detailviewmodel); Guest = new Guest(); Guest_DocumentsViewModel = new Guest_DocumentsViewModel(); RoomReservation_Payment = new RoomReservation_Payment(); Reservation_Total_OtherCurrency = 0; }
public async Task UploadWholeFiles(Guest_DocumentsViewModel docsmodel, HttpContext context) { for (int i = 0; i < context.Request.Files.Count; i++) { var file = context.Request.Files[i]; if (file.FileName != "") { var a_document = docsmodel.InputGuest_Documents[i]; var dirpath = StorageRoot + GuestID + "\\"; if (!Directory.Exists(dirpath)) Directory.CreateDirectory(dirpath); if (a_document.Document_TypeId != 0) { var doc_type = await _Document_TypeRepository.GetById(a_document.Document_TypeId); var count = await _Guest_DocumentsRepository.CountByDocument_TypeId(GuestID.Value, a_document.Document_TypeId) + 1; var filename = doc_type.Name + "_" + count + Path.GetExtension(file.FileName); var fullPath = dirpath + filename; file.SaveAs(fullPath); Guest_Documents newdoc = new Guest_Documents(); newdoc.GuestId = GuestID.Value; newdoc.DocumentURL = StorageURL + GuestID.ToString() + "/" + filename; newdoc.Document_TypeId = a_document.Document_TypeId; await _Guest_DocumentsRepository.Create(newdoc); docsmodel.Guest_Documents.Add(newdoc); } } } }