public async Task <ActionResult> AdminImageUpload(int displayId) { int count = 0; var display = await DisplayRepository.Current.GetDisplay(displayId); if (Request.Files.Count > 0) { for (int i = 0; i < Request.Files.Count; i++) { var postedFile = Request.Files[i]; if (postedFile.ContentLength > 0) { string fileName = Path.GetFileName(postedFile.FileName); Stream source = postedFile.InputStream; var file = await FileModel.Create(fileName, source); await DisplayRepository.Current.AddFile(displayId, file); count++; } } } return(RedirectToAction("Admin", new { displayId })); }
public Task Handle(TcpClient client, IPEndPoint address, List <Tuple <string, int, TcpClient> > usersDict) { return(Task.Factory.StartNew(() => { byte[] data = NetworkInfrastructure.GetNetworkDate(client); InitRequestModel request = Serializers.DeserializeObject <InitRequestModel>(data); usersDict.Add(new Tuple <string, int, TcpClient>(request.UserName, request.Port, client)); var diff = dbHandle.GetDiff(request); diff.ForEach(x => { x.Files.ForEach(async y => { var deserialized = Serializers.SerializeObject <FileModel>(FileModel.Create(x.SerwerName, y.ToString())); await NetworkInfrastructure.SendFileAsync(address.Address, request.Port, deserialized); }); }); client.Dispose(); })); }