protected void vacRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { String element = e.CommandName.ToString(); string userName = (string)Session["username"]; ApplicationDAO app_ctx = new ApplicationDAO(); ApplicationDTO obj = new ApplicationDTO(); if(!app_ctx.isFound(userName,element) ) { obj.userName = userName; obj.vacancyNumber = element; obj.status = ApplicationStatus.APPLIED.ToString(); obj.appDate = DateTime.Now; app_ctx.presist(obj); InboxDTO inbox = new InboxDTO(); inbox.date = DateTime.Now; inbox.message = "You have successfully applied for vacancy " + element; inbox.status = ApplicationStatus.APPLIED.ToString(); inbox.unread = "unread"; inbox.userName = userName; inbox.vacancyNumber = element; InboxDAO dao = new InboxDAO(); dao.presist(inbox); Response.Redirect("~/Inbox/InboxMessage.aspx"); } }
public void ApplicationDAO_Test() { AccountDAO account_context = new AccountDAO(); ApplicationDAO app_context = new ApplicationDAO(); VacancyDAO vac_context = new VacancyDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); VacancyDTO vac = new VacancyDTO(); vac.department = "IS"; vac.description = "Web services"; vac.manager = "Tom"; vac.recruiter = "Thumi"; vac.site = "www.petrosa.co.za"; vac.startDate = new DateTime(2012, 10, 10); vac.endDate = new DateTime(2012, 12, 1); vac.description = "desktop support"; vac.title = "support technician"; vac.vacancyNumber = "1"; vac.viewCount = 10; vac.viewStatus = "published"; vac.status = "active"; vac_context.presist(vac); bool expectedVac = true; bool actualVac; actualVac = vac_context.isFound("1"); Assert.AreEqual(expectedVac, actualVac); ApplicationDTO application = new ApplicationDTO(); application.userName = "******"; application.vacancyNumber = "1"; application.status = "open"; app_context.presist(application); bool expected = true; bool actual; actual = app_context.isFound("griddy", "1"); Assert.AreEqual(expected, actual); /*Update*/ application.status = "closed"; expected = true; actual = app_context.merge(application); Assert.AreEqual(expected, actual); /*Delete*/ Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true); Assert.AreEqual(vac_context.removeByUserId("1"), true); Assert.AreEqual(account_context.removeByUserId("griddy"), true); }
private void changeApplicationStatus(String username, String vacancyNumber, String status) { ApplicationDAO applicationDao = new ApplicationDAO(); ApplicationDTO applicationDto = applicationDao.find(username, vacancyNumber); if (applicationDto != null) { applicationDto.status = status; applicationDao.merge(applicationDto); } }
public List<ApplicationDTO> getApplicationByVacancyNumber(String vacancyNumber) { List<ApplicationDTO> applicationDtoList = new List<ApplicationDTO>(); ; ApplicationDAO applicationDao = new ApplicationDAO(); List<ApplicationDTO> applicationList = applicationDao.findAll(); foreach (ApplicationDTO applicationDto in applicationList) { if (applicationDto.vacancyNumber.Equals(vacancyNumber)) { applicationDtoList.Add(applicationDto); } } return applicationDtoList; }
public List<ApplicationDTO> getApplicationByStatus(String vacancyNumber, String status) { List<ApplicationDTO> applicationDtoList = new List<ApplicationDTO>(); ApplicationDAO applicationDao = new ApplicationDAO(); List<ApplicationDTO> applicationList = getApplicationByVacancyNumber(vacancyNumber); foreach (ApplicationDTO applicationDto in applicationList) { if (applicationDto.status.Equals(status)) { applicationDtoList.Add(applicationDto); } } return applicationDtoList; }
public List<ApplicationDTO> getApplicationByUsername(String username) { List<ApplicationDTO> applicationDtoList = new List<ApplicationDTO>(); ApplicationDAO applicationDao = new ApplicationDAO(); List<ApplicationDTO> applicationList = applicationDao.findAll(); foreach(ApplicationDTO applicationDto in applicationList) { if (applicationDto.userName.Equals(username)) { applicationDtoList.Add(applicationDto); } } return applicationDtoList; }
public List<ApplicationDTO> getApplicationByStatus(String status) { List<ApplicationDTO> applicationDtoList = new List<ApplicationDTO>(); ApplicationDAO applicationDao = new ApplicationDAO(); List<ApplicationDTO> applicationList = applicationDao.findAll(); foreach (ApplicationDTO applicationDto in applicationList) { if (applicationDto.status.Equals(status)) { applicationDtoList.Add(applicationDto); } } return applicationDtoList; }
public ActionResult Summary() { try { if (Session["DevId"] != null) { DeveloperDAO dao = new DeveloperDAO(); UserDAO udao = new UserDAO(); ApplicationDAO adao = new ApplicationDAO(); ViewBag.User = udao.SearchById(int.Parse(Session["Id"].ToString())); Developer d = dao.SearchById(int.Parse(Session["DevId"].ToString())); ViewBag.Apps = adao.GetDevGames(d.Id); ViewBag.Dev = d; return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult NewPhoto(int id, HttpPostedFileBase img) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image im = new Image(); im.Url = "../../../media/app/" + filePath; im.UserId = int.Parse(Session["Id"].ToString()); im.ApplicationId = a.Id; idao.Add(im); return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateAppData(UpdateNotes update, HttpPostedFileBase file) { try { ApplicationDAO dao = new ApplicationDAO(); UpdateNotesDAO updao = new UpdateNotesDAO(); Application app = dao.SearchById(update.ApplicationId); if (int.Parse(Session["DevId"].ToString()) == app.DeveloperId && update.Value != null) { updao.Add(update); //Delete File in Server string p = app.Archive; p = p.Replace("../../..", ".."); string fullPath = Request.MapPath(p); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } //File string filePath2 = Guid.NewGuid() + Path.GetExtension(file.FileName); if (!Directory.Exists(Server.MapPath("~/apps/appfiles/" + app.Id))) { Directory.CreateDirectory(Server.MapPath("~/apps/appfiles/" + app.Id)); } file.SaveAs(Path.Combine(Server.MapPath("~/apps/appfiles/" + app.Id), filePath2)); app.Archive = "../../../apps/appfiles/" + app.Id + "/" + filePath2; dao.Update(); // return(RedirectToAction("Summary", "Developer")); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateInfo(Application app) { try { if (Session["ModId"] != null || app.DeveloperId == int.Parse(Session["DevId"].ToString())) { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(app.Id); a.Name = app.Name; a.Desc = app.Desc; a.Price = app.Price; a.TypeAppId = app.TypeAppId; a.PegiId = app.PegiId; dao.Update(); return(RedirectToAction("EditApp", "Application", new { id = app.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Library() { try { if (Session["Id"] != null) { CartDAO cardao = new CartDAO(); SellItemDAO sidao = new SellItemDAO(); SellDAO sdao = new SellDAO(); ApplicationDAO appdao = new ApplicationDAO(); IList <SellItem> si = sidao.GetUserApps(int.Parse(Session["Id"].ToString())); ViewBag.UserApps = si; ViewBag.AppsinLib = appdao.GetAppsInLibrary(si); ViewBag.Sells = sdao.GetUserSells(int.Parse(Session["Id"].ToString())); ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString())); return(View()); } return(RedirectToAction("../Home/Index")); } catch { return(RedirectToAction("Index", "Home")); } }
public static void Begin(Application application) { int beforeCount = 0; int afterCount = 0; // Application API List <Application> applications; // Get exsisting beforeCount = ApplicationDAO.Get().Count; // Insert and Updating: if ID is included, it will update application = ApplicationDAO.PostUpdate(application); // Reading: Use GetApplications() to retrieve a list of applicationlications applications = ApplicationDAO.Get(); // get master item count afterCount = applications.Count; // write ApplicationTest.Write(applications, "INSERT", beforeCount, afterCount, true); Console.Read(); // make a soft update to some property application.name = "TEST_UPDATE"; // re-assign the before count beforeCount = afterCount; // Insert and Updating: if ID is included, it will update application = ApplicationDAO.PostUpdate(application); // Reading: Use GetApplications() to retrieve a list of applicationlications applications = ApplicationDAO.Get(); // Get exsisting afterCount = ApplicationDAO.Get().Count; // write ApplicationTest.Write(applications, "UPDATE", beforeCount, afterCount); Console.Read(); // get a single applicationlication (returns a list) applications = ApplicationDAO.Get(application); // get count afterCount = applications.Count; // reassign count beforeCount = afterCount; // write ApplicationTest.Write(applications, "Single", afterCount, 1); Console.Read(); // Deleting - Send in the applicationlication w/ at minimal the ID populated ApplicationDAO.Delete(application); // Reading: Use GetApplications() to retreieve a list of applicationlications applications = ApplicationDAO.Get(); // get count afterCount = applications.Count; // write ApplicationTest.Write(applications, "Removed", beforeCount, afterCount, true); Console.Read(); }
public void userServiceTest() { UserService target = CreateUserService(); // TODO: Initialize to an appropriate value AccountDAO account_context = new AccountDAO(); ApplicationDAO app_context = new ApplicationDAO(); VacancyDAO vac_context = new VacancyDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); VacancyDTO vac = new VacancyDTO(); vac.department = "IS"; vac.description = "Web services"; vac.manager = "Tom"; vac.recruiter = "Thumi"; vac.site = "www.petrosa.co.za"; vac.startDate = new DateTime(2012, 10, 10); vac.endDate = new DateTime(2012, 12, 1); vac.description = "desktop support"; vac.title = "support technician"; vac.vacancyNumber = "1"; vac.viewCount = 10; vac.viewStatus = "published"; vac.status = "active"; vac_context.presist(vac); bool expectedVac = true; bool actualVac; actualVac = vac_context.isFound("1"); Assert.AreEqual(expectedVac, actualVac); ApplicationDTO applicationDto = new ApplicationDTO(); applicationDto.userName = "******"; applicationDto.vacancyNumber = "1"; applicationDto.status = ApplicationStatus.APPLIED.ToString(); app_context.presist(applicationDto); bool expected = true; bool actual; actual = app_context.isFound("griddy", "1"); Assert.AreEqual(expected, actual); //Test changeUserApplicationStatus method target.changeUserApplicationStatus("griddy", "1", ApplicationStatus.SHORTLISTED); ApplicationDTO applicationDto2 = app_context.find("griddy", "1"); Assert.AreEqual(ApplicationStatus.SHORTLISTED.ToString(), applicationDto2.status); //Test getShortListedCandidates method List<ApplicationDTO> candidates = target.getShortListedCandidates("1"); Assert.AreEqual("griddy", candidates[0].userName); /*Delete*/ Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true); Assert.AreEqual(vac_context.removeByUserId("1"), true); Assert.AreEqual(account_context.removeByUserId("griddy"), true); }
public async Task<ActionResult> Create(FormCollection collection) { try { if (!string.IsNullOrEmpty(Request.Form["FirstName"]) && !string.IsNullOrEmpty(Request.Form["LastName"]) && !string.IsNullOrEmpty(Request.Form["SSN"]) && Request.Form["acknowledgeAccurateDataCheckbox"] != null) { // save application form data back to database through service using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri("http://localhost:51309"); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage result = new HttpResponseMessage(); string resultContent = ""; // gather Applicant form data ApplicantDAO applicant = new ApplicantDAO(); applicant.FirstName = Request.Form["FirstName"]; applicant.MiddleName = Request.Form["MiddleName"]; applicant.LastName = Request.Form["LastName"]; applicant.SSN = Request.Form["SSN"]; applicant.ApplicantAddress = Request.Form["ApplicantAddress"]; applicant.Phone = Request.Form["ApplicantPhone"]; applicant.NameAlias = Request.Form["NameAlias"]; // post (save) applicant data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceApplicantUri, applicant).Result; resultContent = result.Content.ReadAsStringAsync().Result; // gather Application form data ApplicationDAO application = new ApplicationDAO(); application.ApplicationStatus = "Submitted"; application.SalaryExpectation = Request.Form["SalaryExpectation"]; application.FullTime = Convert.ToByte(Request.Form["FullTime"]); application.AvailableForDays = Convert.ToByte(Request.Form["AvailableForDays"]); application.AvailableForEvenings = Convert.ToByte(Request.Form["AvailableForEvenings"]); application.AvailableForWeekends = Convert.ToByte(Request.Form["AvailableForWeekends"]); application.MondayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["MondayFrom"])); application.TuesdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["TuesdayFrom"])); application.WednesdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["WednesdayFrom"])); application.ThursdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["ThursdayFrom"])); application.FridayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["FridayFrom"])); application.SaturdayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SaturdayFrom"])); application.SundayFrom = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SundayFrom"])); application.MondayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["MondayTo"])); application.TuesdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["TuesdayTo"])); application.WednesdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["WednesdayTo"])); application.ThursdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["ThursdayTo"])); application.FridayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["FridayTo"])); application.SaturdayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SaturdayTo"])); application.SundayTo = System.TimeSpan.FromHours(Convert.ToDouble(Request.Form["SundayTo"])); // post (save) application data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceApplicationUri, application).Result; resultContent = result.Content.ReadAsStringAsync().Result; // get correct applicant id // TODO: there is still something we might need to change about this... // ***** We don't, it's safe to assume that id would be the last item on the list // since we're using auto incremented id. ***** var applicants = await ServerResponse<List<ApplicantDAO>>.GetResponseAsync(ServiceURIs.ServiceApplicantUri); ; applicant.ApplicantID = applicants.Last().ApplicantID; // get correct application id // TODO: there is still something we might need to change about this... var applications = await ServerResponse<List<ApplicationDAO>>.GetResponseAsync(ServiceURIs.ServiceApplicationUri); application.ApplicationID = applications.Last().ApplicationID; // Create Applied DAO; AppliedDAO applied = new AppliedDAO(); applied.ApplicantID = applicant.ApplicantID; applied.ApplicationID = application.ApplicationID; applied.JobOpeningID = Convert.ToInt32(Request.Form["JobOpeningIDReferenceNumber"]); applied.DateApplied = DateTime.Now; // post (save) applied data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceAppliedUri, applied).Result; resultContent = result.Content.ReadAsStringAsync().Result; // gather Employer data EmployerDAO employer = new EmployerDAO(); var employers = await ServerResponse<List<EmployerDAO>>.GetResponseAsync(ServiceURIs.ServiceEmployerUri); EmploymentDAO employment = new EmploymentDAO(); for (int i = 1; i < 4; i++) { // make sure this form item is filled in... if ((!string.IsNullOrWhiteSpace(Request.Form["EmployerName_" + i]) && !string.IsNullOrWhiteSpace(Request.Form["EmployerAddress_" + i]))) { employer.Name = Request.Form["EmployerName_" + i]; employer.EmployerAddress = Request.Form["EmployerAddress_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployerPhone_" + i])) employer.PhoneNumber = Request.Form["EmployerPhone_" + i]; //if (!string.IsNullOrWhiteSpace(employer.Name)) //{ // TODO: check if employer already exists in database // TODO: if employer exists in database: don't insert data // if employer !exists in database: insert data // post (save) employer data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEmployerUri, employer).Result; resultContent = result.Content.ReadAsStringAsync().Result; //} // get correct employer id // TODO: there is still something we might need to change about this... employers = await ServerResponse<List<EmployerDAO>>.GetResponseAsync(ServiceURIs.ServiceEmployerUri); ; employer.EmployerID = employers.Last().EmployerID; // gather Employment data employment = new EmploymentDAO(); employment.ApplicantID = applicant.ApplicantID; employment.EmployerID = employer.EmployerID; if (!string.IsNullOrWhiteSpace(Request.Form["MayWeContactCurrentEmployer_" + i])) employment.MayWeContactCurrentEmployer = Convert.ToByte(Request.Form["MayWeContactCurrentEmployer_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["EmployedFrom_" + i])) employment.EmployedFrom = Convert.ToDateTime(Request.Form["EmployedFrom_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["EmployedTo_" + i])) employment.EmployedTo = Convert.ToDateTime(Request.Form["EmployedTo_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["EmployerSupervisor_" + i])) employment.Supervisor = Request.Form["EmployerSupervisor_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployedPosition_" + i])) employment.Position = Request.Form["EmployedPosition_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployedStartingSalary_" + i])) employment.StartingSalary = Request.Form["EmployedStartingSalary_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployedEndingSalary_" + i])) employment.EndingSalary = Request.Form["EmployedEndingSalary_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployedReasonForLeaving_" + i])) employment.ReasonForLeaving = Request.Form["EmployedReasonForLeaving_" + i]; if (!string.IsNullOrWhiteSpace(Request.Form["EmployedResponsibilities_" + i])) employment.Responsibilities = Request.Form["EmployedResponsibilities_" + i]; // post (save) employment data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEmploymentUri, employment).Result; resultContent = result.Content.ReadAsStringAsync().Result; } } // gather School and Education data SchoolDAO school = new SchoolDAO(); var schools = await ServerResponse<List<SchoolDAO>>.GetResponseAsync(ServiceURIs.ServiceSchoolUri); EducationDAO education = new EducationDAO(); for (int i = 1; i < 4; i++) { // make sure this form item is filled in... if ((!string.IsNullOrWhiteSpace(Request.Form["SchoolName_" + i]) && !string.IsNullOrWhiteSpace(Request.Form["SchoolAddress_" + i]))) { school = new SchoolDAO(); school.SchoolName = Request.Form["SchoolName_" + i]; school.SchoolAddress = Request.Form["SchoolAddress_" + i]; //if (!string.IsNullOrWhiteSpace(school.SchoolName)) //{ // TODO: check if school already exists in database // TODO: if school exists in database: don't insert data // if school !exists in database: insert data // post (save) school data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceSchoolUri, school).Result; resultContent = result.Content.ReadAsStringAsync().Result; //} // get correct school id // TODO: there is still something we might need to change about this... schools = await ServerResponse<List<SchoolDAO>>.GetResponseAsync(ServiceURIs.ServiceSchoolUri); school.SchoolID = schools.Last().SchoolID; // gather Education data education = new EducationDAO(); education.ApplicantID = applicant.ApplicantID; education.SchoolID = school.SchoolID; if (!string.IsNullOrWhiteSpace(Request.Form["YearsAttendedFrom_" + i])) education.YearsAttendedFrom = Convert.ToDateTime(Request.Form["YearsAttendedFrom_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["YearsAttendedTo_" + i])) education.YearsAttendedTo = Convert.ToDateTime(Request.Form["YearsAttendedTo_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["Graduated_" + i])) education.Graduated = Convert.ToByte(Request.Form["Graduated_" + i]); if (!string.IsNullOrWhiteSpace(Request.Form["DegreeAndMajor_" + i])) education.DegreeAndMajor = Request.Form["DegreeAndMajor_" + i]; // post (save) education data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceEducationUri, education).Result; resultContent = result.Content.ReadAsStringAsync().Result; } } } try { // redirect to assessment questions, if possible return RedirectToAction("Create", "Assessments", new { ID = Convert.ToInt32(Request.Form["JobOpeningIDReferenceNumber"]) }); } catch { return RedirectToAction("Welcome", "Home"); } } else { // TODO: validation later on... return RedirectToAction("Create"); } } catch { // TODO: validation later on... return RedirectToAction("Create"); } }
public bool PostApplication(ApplicationDAO app) { ApplicationServiceClient client = new ApplicationServiceClient(); try { bool result = false; // are we editing or creating this item? if (app.ApplicationID > 0) result = client.UpdateApplication(app); else result = client.CreateApplication(app); return result; } catch (FaultException<KaskServiceException> e) { throw new HttpException(e.Message); } }
public ActionResult Validate(Application app, IList <HttpPostedFileBase> images, HttpPostedFileBase File, IList <Genre> genres) { var result = ""; if (ModelState.IsValid) { try { app.Approved = 0; ApplicationDAO dao = new ApplicationDAO(); Application uniq = dao.IsUnique(app); DeveloperDAO ddao = new DeveloperDAO(); ImageDAO idao = new ImageDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); Developer Dev = ddao.SearchById(int.Parse(Session["DevId"].ToString())); bool ImgError = false, FileError = false, AGError = false; if (Dev != null) { if (app.ReleaseDate.Year >= 1900 && app.ReleaseDate.Year <= DateTime.Now.Year + 1) { if (app.Price >= 0 && app.Price <= 1000) { if (uniq == null) { app.DeveloperId = Dev.Id; dao = new ApplicationDAO(); dao.Add(app); Dev.NumSoft++; ddao.Update(); Application appreg = dao.GetDevLastGame(Dev.Id); try { foreach (var g in genres) { if (g.IsChecked == true) { ApplicationGenre ag = new ApplicationGenre(); ag.ApplicationId = appreg.Id; ag.GenreId = g.Id; agdao.Add(ag); } } } catch { AGError = true; } try { //Images int count = 0; foreach (var img in images) { string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image i = new Image(); i.Url = "../../../media/app/" + filePath; i.UserId = int.Parse(Session["Id"].ToString()); i.ApplicationId = appreg.Id; idao.Add(i); if (count == 0) { appreg.ImageUrl = i.Url; count++; dao.Update(); } } // } catch { appreg.ImageUrl = "../../../assets/images/game-kingdoms-of-amalur-reckoning-4-500x375.jpg"; dao.Update(); ImgError = true; result = result + "Error on Uploading Images, try later"; } try { //File string filePath2 = Guid.NewGuid() + Path.GetExtension(File.FileName); if (!Directory.Exists(Server.MapPath("~/apps/appfiles/" + appreg.Id))) { Directory.CreateDirectory(Server.MapPath("~/apps/appfiles/" + appreg.Id)); } File.SaveAs(Path.Combine(Server.MapPath("~/apps/appfiles/" + appreg.Id), filePath2)); appreg.Archive = "../../../apps/appfiles/" + appreg.Id + "/" + filePath2; dao.Update(); // } catch { FileError = true; result = result + "Error on Uploading Files, try later"; } if (ImgError || FileError || AGError) { return(Json(result, JsonRequestBehavior.AllowGet)); } result = "Successfully Registered"; return(Json(result, JsonRequestBehavior.AllowGet)); //return RedirectToAction("Register"); } else { result = "There is already a game with this name"; return(Json(result, JsonRequestBehavior.AllowGet)); } } else { result = "Application Price is not acceptable"; return(Json(result, JsonRequestBehavior.AllowGet)); } } else { result = "The release date is not acceptable"; return(Json(result, JsonRequestBehavior.AllowGet)); } } else { result = "You are not a Developer"; return(Json(result, JsonRequestBehavior.AllowGet)); } } catch { ViewBag.App = app; result = "An Error Occurred"; return(Json(result, JsonRequestBehavior.AllowGet)); //return RedirectToAction("Register"); } } ViewBag.App = app; ViewBag.Class = "alert alert-danger"; result = "An Error Occurred"; return(Json(result, JsonRequestBehavior.AllowGet)); //return View("Register"); }
public void applicationSearchServiceTest() { ApplicationSearchService target = new ApplicationSearchServiceImpl(); // TODO: Initialize to an appropriate value AccountDAO account_context = new AccountDAO(); ApplicationDAO app_context = new ApplicationDAO(); VacancyDAO vac_context = new VacancyDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); VacancyDTO vac = new VacancyDTO(); vac.department = "IS"; vac.description = "Web services"; vac.manager = "Tom"; vac.recruiter = "Thumi"; vac.site = "www.petrosa.co.za"; vac.startDate = new DateTime(2012, 10, 10); vac.endDate = new DateTime(2012, 12, 1); vac.description = "desktop support"; vac.title = "support technician"; vac.vacancyNumber = "1"; vac.viewCount = 10; vac.viewStatus = "published"; vac.status = "active"; vac_context.presist(vac); bool expectedVac = true; bool actualVac; actualVac = vac_context.isFound("1"); Assert.AreEqual(expectedVac, actualVac); ApplicationDTO application = new ApplicationDTO(); application.userName = "******"; application.vacancyNumber = "1"; application.status = "open"; app_context.presist(application); //Test getApplicationByUsername method List<ApplicationDTO> applicationTestListObj = target.getApplicationByUsername("graddy"); Assert.AreEqual(application.status, applicationTestListObj[0].status); //Test getApplicationByStatus method List<ApplicationDTO> applicationTestListObj2 = target.getApplicationByStatus("open"); Assert.AreEqual(application.status, applicationTestListObj2[0].status); //Test getApplicationByVacancyNumber method List<ApplicationDTO> applicationTestListObj3 = target.getApplicationByVacancyNumber("1"); Assert.AreEqual(application.status, applicationTestListObj3[0].status); /*Delete*/ /* account_context.removeByUserId("graddy"); bool expectedDelete = false; bool actualDelete = account_context.isFound("graddy"); Assert.AreEqual(expectedDelete, actualDelete); */ }
public SecurityService(string context) { _userDAO = new UserDAO(context); _applicationDAO = new ApplicationDAO(context); _smtpService = new SmtpService(); }
public ActionResult Reject(FormCollection collection) { try { if (!string.IsNullOrEmpty(Request.Form["ApplicationID"])) { // save application form data back to database through service using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri("http://localhost:51309"); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage result = new HttpResponseMessage(); string resultContent = ""; // gather application form data ApplicationDAO updatedApp = new ApplicationDAO(); updatedApp.ApplicationID = Convert.ToInt32(Request.Form["ApplicationID"]); updatedApp.ApplicationStatus = "Rejected"; // post (save) application data result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceApplicationUri, updatedApp).Result; resultContent = result.Content.ReadAsStringAsync().Result; } return RedirectToAction("Index", "App"); } else { // TODO: validation later on... return RedirectToAction("Index", "App"); } } catch { // TODO: validation later on... return RedirectToAction("Index", "App"); } }
/// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary> /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="relations">The set of relations to walk to construct to total query.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>DataTable with the rows requested.</returns> public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize) { ApplicationDAO dao = DAOFactory.CreateApplicationDAO(); return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize)); }