static void Main(string[] args) { ChannelFactory <IStudents> factory = new ChannelFactory <IStudents>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8888/InputRequest")); IStudents proxy = factory.CreateChannel(); int i = 5; while (true) { if (proxy.AddStudent(++i, $"ime{i}", $"prezime{i}")) { Console.WriteLine("Student added"); } else { Console.WriteLine("Student not added"); } Thread.Sleep(5000); } }
public IActionResult createStudent(StudentCreateView model) { if (ModelState.IsValid) { string uniqueFileName = null; if (model.Image != null) { string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Image.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); model.Image.CopyTo(new FileStream(filePath, FileMode.Create)); } Student newStudent = new Student() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Gender = model.Gender, Address = model.Address, BVN = model.BVN, AddmissionType = model.AddmissionType, NextOfKinDocumentUrl = model.NextOfKinDocumentUrl, NextOfKinEmail = model.NextOfKinEmail, NextOfKinName = model.NextOfKinName, NextOfKinPhone = model.NextOfKinPhone, MaritalStatus = model.MaritalStatus, Nationality = model.Nationality, ImagePath = uniqueFileName, Phone = model.Phone, DateOfBirth = model.DateOfBirth, }; Student stu = _student.AddStudent(newStudent); return(RedirectToAction("create", "Guarantor", new { id = stu.ID })); //return RedirectToAction("dashboard"); } return(View()); }