// GET: Applications/Create public ActionResult New(string param) { var user = db.AspNetUsers.Find(User.Identity.GetUserId()); if (String.IsNullOrEmpty(user.SocialClubName)) { return(RedirectToAction("Configuration", "Home")); } if (param == "new") { var userId = User.Identity.GetUserId(); var app = db.Applications.FirstOrDefault(x => x.UserID == userId); app.Answers.Clear(); db.Applications.Remove(app); db.SaveChanges(); } ApplicationModel appModel = new Models.ApplicationModel(); Random r = new Random(); var question = db.Questions.ToList().OrderBy(x => Guid.NewGuid()); foreach (var item in question) { appModel.Answers.Add(new AnswerField(item.QuestionID, item.QuestionText, item.IsTextArea, item.Selection_A, item.Selection_B, item.Selection_C)); } if (appModel.Answers.Count <= 0) { return(RedirectToAction("Index", "Home")); } return(View(appModel)); }
public ActionResult MemberInformationSummary(Int64 memberId) { Models.ApplicationModel applicationModel = new Models.ApplicationModel(); Client.Core.Member.Member member = applicationModel.MercuryApplication.MemberGet(memberId, true); return(View("~/Views/Controls/MemberInformationSummary.cshtml", member)); }
public ActionResult Create(Models.ApplicationModel app) { try { if (!ModelState.IsValid) { return(View("Create", app)); } string cv = app.files[0].FileName; string idpic = app.files[1].FileName; string yellow = app.files[2].FileName; var guid = Guid.NewGuid().ToString(); FtpClient client = new FtpClient("deliverit.westeurope.cloudapp.azure.com"); client.Connect(); client.CreateDirectory($"public_html/Files/{guid}"); /*foreach (var a in app.files) * { * FileStream fs = System.IO.File.Create(path + $"/{guid}/{a.FileName}"); * a.InputStream.CopyTo(fs); * fs.Close(); * }*/ client.Upload(app.files[0].InputStream, $"public_html/Files/{guid}/{cv}"); client.Upload(app.files[1].InputStream, $"public_html/Files/{guid}/{idpic}"); client.Upload(app.files[2].InputStream, $"public_html/Files/{guid}/{yellow}"); var result = _proxy.AddApplication(new ApplicationResource { Address = app.Address, City = app.City, Cpr = app.Cpr, Email = app.Email, FirstName = app.FirstName, LastName = app.LastName, PhoneNumber = app.PhoneNumber, ZipCode = app.ZipCode, CVPath = cv, IDPicturePath = idpic, YellowCardPath = yellow, GuidLine = guid }); client.Disconnect(); if (result == 1) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Create", app)); } } catch (Exception e) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
public void AddApplicationToDB(string cpr, string firstName, string lastName, string phone, string email, string address, string zipCode, string city, string cvpath, string idpicturepath, string yellowcardpath) { //setup var courierServiceMock = new Mock <ISenderService>(); var app = new Models.ApplicationModel { Cpr = cpr, FirstName = firstName, LastName = lastName, PhoneNumber = phone, Email = email, Address = address, ZipCode = zipCode, City = city, files = new System.Web.HttpPostedFileBase[3] }; //senderServiceMock.Setup(x => x.AddSender(senderToService)).Returns(1); courierServiceMock.Setup(x => x.AddApplication(It.IsAny <SenderServiceReference1.ApplicationResource>())).Returns(1); var sut = new ApplicationController(courierServiceMock.Object); var res = sut.Create(app); //assert Assert.AreNotEqual(app, new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); }
public ActionResult DeleteOnDecline(Models.ApplicationModel app) { try { if (!ModelState.IsValid) { return(View("Index")); } ApplicationResource appToDelete = new ApplicationResource { Cpr = app.Cpr }; _proxy.DeleteApplication(appToDelete, true); //client.Disconnect(); return(RedirectToAction("Index")); } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
public async void Should_Return_The_Application_After_Saving() { // Arrange var app = new Models.ApplicationModel() { Application = 1, Url = "http://wwww.mynumberis27.com/", PathLocal = Environment.CurrentDirectory, DebuggingMode = true }; // Act var appResult = await _appService.SaveApplication(app); // Assert Assert.Equal(app.Application, appResult.Application); Assert.Equal(app.Url, appResult.Url); Assert.Equal(app.PathLocal, appResult.PathLocal); Assert.Equal(app.DebuggingMode, appResult.DebuggingMode); }
public async void Should_Return_The_Application_After_Updating() { // Arrange int applicationUpdateId = 27; var app = new Models.ApplicationModel() { Application = 1, Url = "http://wwww.mynumberis27.com/", PathLocal = Environment.CurrentDirectory, DebuggingMode = true }; // Act var appResult = await _appService.UpdateApplication(applicationUpdateId, new Microsoft.AspNetCore.JsonPatch.JsonPatchDocument <Models.ApplicationModel>()); // Assert Assert.Equal(applicationUpdateId, appResult.Application); Assert.Equal(app.Url, appResult.Url); Assert.Equal(app.PathLocal, appResult.PathLocal); Assert.Equal(app.DebuggingMode, appResult.DebuggingMode); }