public ActionResult ChangeRepresentative(string employee, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; long currentRep = DepartmentService.GetCurrentRep(deptId); bool all = DelegateService.CheckPreviousHeadForNav(deptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; if (employee != null) { long newRep = long.Parse(employee); EmailNotification notice = new EmailNotification(); RepresentativeService.UpdateEmployeeRole(newRep, currentRep, deptId); Employee newRepMailReceiver = EmployeeService.GetEmployeeById(newRep); Employee oldRepMailReceiver = EmployeeService.GetEmployeeById(currentRep); Task.Run(() => { notice.ReceiverMailAddress = newRepMailReceiver.Email; emailService.SendMail(notice, EmailTrigger.ON_ASSIGNED_AS_DEPT_REP); notice.ReceiverMailAddress = oldRepMailReceiver.Email; emailService.SendMail(notice, EmailTrigger.ON_REMOVED_DEPT_REP); }); } List <Employee> employees = RepresentativeService.GetEmployeesByDepartment(deptId); ViewData["employees"] = employees; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult FilterSearch(RepresentativeSearchModel searchModel) { RepresentativeService service = new RepresentativeService(); RepresentativeListModel resultModel = service.SearchForRepresentativesForParliament(searchModel); return(PartialView("_RepresentativesSearchResult", resultModel)); }
public ActionResult RepresentativeDetails(int repId) { var service = new RepresentativeService(); var model = service.GetRepresentativeEditModel(repId); return(View(model)); }
public ActionResult CreateRepresentative(int parliamentHouseId) { RepresentativeService service = new RepresentativeService(); RepresentativeEditModel model = service.InitializeRepresentativeModelForCreate(parliamentHouseId); return(View(model)); }
public ActionResult DeleteRepresentative(int repId, string test) { RepresentativeService service = new RepresentativeService(); service.DeleteRepresentative(repId); return(RedirectToAction("ManageRepresentatives")); }
public ActionResult ManageRepresentativeExternalLinks(int repId) { RepresentativeService service = new RepresentativeService(); RepresentativeEditModel model = service.GetRepresentativeEditModel(repId); return(View(model)); }
public ActionResult DeleteRepresentativeAssignment(int assignmentId) { RepresentativeService service = new RepresentativeService(); var isDeleted = service.DeleteAssignment(assignmentId); return(Json(new { isDeleted = isDeleted, assignmentId = assignmentId }, JsonRequestBehavior.AllowGet));; }
public ActionResult DeleteRepresentative(int repId) { RepresentativeService service = new RepresentativeService(); RepresentativeEditModel model = service.GetRepresentativeEditModel(repId); return(View(model)); }
public ActionResult DeleteRepresentativeExternalLinkItem(int externalLinkID) { RepresentativeService service = new RepresentativeService(); var isDeleted = service.DeleteExternalLink(externalLinkID); return(Json(new { isDeleted = isDeleted, externalLinkID = externalLinkID }, JsonRequestBehavior.AllowGet));; }
public ActionResult CreateRepresentativeAssignment(int representativeId, RepresentativeAssignmentModel model) { TryUpdateModel(model); RepresentativeService service = new RepresentativeService(); model = service.CreateAssignment(representativeId, model.Title); return(PartialView("_RepresentativeAssignmentItem", model)); }
public ActionResult EditRepresentative(RepresentativeEditModel model) { TryUpdateModel(model); RepresentativeService service = new RepresentativeService(); model = service.UpdateRepresentative(model); return(RedirectToAction("RepresentativeDetails", new { repId = model.RepresentativeID })); }
public ActionResult CreateRepresentativeExternalLink(int representativeId, RepresentativeExternalLinkModel model) { TryUpdateModel(model); RepresentativeService service = new RepresentativeService(); model = service.CreateLink(representativeId, model.Description, model.Url); return(PartialView("_RepresentativeExternalLinkItem", model)); }
public ActionResult Index(string pCode) { var parliamentId = new ParliamentService().GetParliamentId(pCode); RepresentativeService service = new RepresentativeService(); RepresentativeListModel model = service.GetAllRepresentativesForParliament(parliamentId); return(View(model)); }
public ActionResult CreateRepresentative(RepresentativeEditModel model) { TryUpdateModel(model); RepresentativeService service = new RepresentativeService(); var representativeId = service.CreateRepresentative(model); return(RedirectToAction("RepresentativeDetails", new { repId = representativeId })); }
public ActionResult ManageRepresentatives() { if (SessionManager.Current.CurrentParliamentId == 0) { SessionManager.Current.CurrentParliamentId = 1; } RepresentativeService service = new RepresentativeService(); RepresentativeListModel model = service.GetAllRepresentativesForParliament(SessionManager.Current.CurrentParliamentId); return(View(model)); }
public void GetRepresentative_First_Returned() { int firstId = 0; using (var context = JavnaRasprava.WEB.DomainModels.ApplicationDbContext.Create()) { firstId = context.Representatives.First().RepresentativeID; var response = new RepresentativeService().GetRepresentative(firstId); Assert.IsNotNull(response); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { lblCurrentTitle.Text = $"{ClientAction} Client"; SSN.Text = ClientSSN; var representatives = RepresentativeService.GetAll(); ddlRepresentative.DataSource = representatives; ddlRepresentative.DataValueField = "RepresentativeID"; ddlRepresentative.DataTextField = "FullName"; ddlRepresentative.DataBind(); ddlRepresentative.Items.Insert(0, ""); } }
public void GetAllRepresentativesForParliament_First_Returned() { int stateId = 0; using (var context = JavnaRasprava.WEB.DomainModels.ApplicationDbContext.Create()) { stateId = context.Parliaments.Where(x => x.Name == StringConstants.PARLIAMENT_NAME_STATE).First().ParliamentID; var response = new RepresentativeService().GetAllRepresentativesForParliament(stateId); Assert.IsNotNull(response); Assert.AreEqual(2, response.ParliamentHouses.Count()); } }
public void SaveRequest(ADProjectDb db, int itemCatalogueId, int quantity, bool?isUpdate, int?requestId) { using (db) { Employee employee = GetEmployee(db); RequestStatus requestStatus = db.RequestStatus.Where(rs => rs.RequestStatusDescription == StatusEnums.RequestStatusEnum.PENDING.ToString()).SingleOrDefault(); ItemCatalogue itemCatalogue = db.ItemCatalogue.Where(ic => ic.ItemCatalogueId == itemCatalogueId).SingleOrDefault(); Request request = new Request(); RequestDetail requestDetail = new RequestDetail(); //if update instead of create... isUpdate = (isUpdate == null ? false : isUpdate); if ((bool)isUpdate) { request = db.Request.Where(r => r.RequestId == requestId).SingleOrDefault(); requestDetail = db.RequestDetail.Where(rd => rd.Request.RequestId == requestId).SingleOrDefault(); } request.Department = employee.Department; request.RaisedByEmployee = employee; request.RequestDate = DateTime.Today; request.RequestStatus = requestStatus; RepresentativeService representativeService = new RepresentativeService(); CollectionPoint collectionPoint = representativeService.GetLatestCollectionPoint(db); request.CollectionPoint = collectionPoint; requestDetail.ItemCatalogue = itemCatalogue; requestDetail.Quantity = quantity; requestDetail.Request = request; if (isUpdate == false) { db.Request.Add(request); db.RequestDetail.Add(requestDetail); } db.SaveChanges(); Request lastestAddedRequest = db.Request.OrderByDescending(r => r.RequestId).FirstOrDefault(); } }
public void GetRepresentative_OnSeedFirstSDP_QuestionDetailsReturned() { var seed = Helpers.GetTestLawExtended(); var sdaRep = seed.LawRepresentativeAssociations .Where(x => x.Representative.Party.Name == "SDA") .FirstOrDefault(); var sdpRep = seed.LawRepresentativeAssociations .Where(x => x.Representative.Party.Name == "SDP") .FirstOrDefault(); var response = new RepresentativeService().GetRepresentative(sdpRep.RepresentativeID); Assert.AreEqual(1, response.TotalQuestions, "Total Questions"); Assert.AreEqual(0, response.TotalAnswers, "Total Answers"); Assert.AreEqual(1, response.Laws.Count, "Total Laws"); Assert.AreEqual(1, response.Laws[0].Questions.Count, "Total Question objects"); Assert.IsNull(response.Laws[0].Questions[0].Answer, "Answer exists"); }
protected void CreateUser_Click(object sender, EventArgs e) { Domain.Entities.User user = new User() { Username = Username.Text, Password = Password.Text, DateAdded = DateTime.Now, Locked = false, RoleID = Role.SelectedValue.ToInt() }; UserService.AddUser(user); Domain.Entities.Representative representative = new Representative() { UserID = user.UserID, FirstName = FirstName.Text, MiddleName = MiddleName.Text, LastName = LastName.Text, Active = Active.Checked ?true:false, DateAdded = DateTime.Now }; RepresentativeService.AddRepresentative(representative); Response.Redirect("~/ClientMaintenance/SearchClient.aspx"); }
public ActionResult Representative(string pCode, int?repID) { if (repID == null) { return(HttpNotFound("No such Representative Found")); } RepresentativeService service = new RepresentativeService(); RepresentativeModel model = service.GetRepresentative(repID.Value, User.Identity.GetUserId()); if (model == null) { return(HttpNotFound("No such Representative Found")); } if (pCode == null || pCode != model.Representative.ParliamentHouse.Parliament.Code) { return(RedirectToRoute(Resources.Routes.Representatives_Representative, new { pCode = model.Representative.ParliamentHouse.Parliament.Code, repID })); } return(View("Representative", model)); }
public ActionResult Index(string pcode) { var parliamentService = new ParliamentService(); var parliamentId = parliamentService.GetParliamentId(pcode); var service = new LawService(); var repService = new RepresentativeService(); var model = new LawHomeModel(); model.LatestLaws = service.GetLatestLaws(AppConfig.GetIntValue("JavnaRasprava.Index.LatestLaws", 5), parliamentId); model.LatestLaws.Title = GlobalLocalization.LatestLawsTitle; model.MostActive = service.GetMostActive(AppConfig.GetIntValue("JavnaRasprava.Index.MostActive", 5), parliamentId); model.MostActive.Title = GlobalLocalization.MostActiveLawsTitle; model.NextLawsInVote = service.GetNextLawsInVote(AppConfig.GetIntValue("JavnaRasprava.Index.NextLawsInVote", 5), parliamentId); model.NextLawsInVote.Title = GlobalLocalization.NextLawsInVoteTitle; model.TopRepresentatives = repService.GetTopRepresentatives(Infrastructure.AppConfig.GetIntValue("JavnaRasprava.Index.TopRepresentatives", 5), parliamentId); model.Search = service.InitializeSearchModel(); return(View(model)); }
public ActionResult ViewDelegate(Models.Delegate d, string delegatedhead, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; List <Employee> employees = RepresentativeService.GetEmployeesByDepartment(deptId); long headId = DepartmentService.GetCurrentHead(deptId); Employee e = EmployeeDAO.GetEmployeeById(headId); ViewData["currentHead"] = e; ViewData["employees"] = employees; ViewData["timeErr"] = false; bool all = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = all; ViewData["sessionId"] = sessionId; if (delegatedhead == null && d.Employee == null) { if (DelegateService.CheckDelegatedByDept(deptId)) { ViewData["delegated"] = true; } else { ViewData["delegated"] = false; } return(View()); } else if (delegatedhead == null && d.Employee != null) { d.Department = new Department(); d.Department.DeptId = deptId; bool isThereDelegate = DelegateService.CheckDelegatedByDept(deptId); bool timeErr = (d.FromDate < DateTime.Now && d.ToDate < DateTime.Now); ViewData["timeErr"] = timeErr; if (!isThereDelegate && !timeErr) { DelegateService.AddNewDelegate(d, headId); EmailNotification notice = new EmailNotification(); Employee MailReceiver = EmployeeService.GetEmployeeById(d.Employee.EmpId); notice.ReceiverMailAddress = MailReceiver.Email; notice.From = d.FromDate; notice.To = d.ToDate; Task.Run(() => emailService.SendMail(notice, EmailTrigger.ON_DELEGATED_AS_DEPT_HEAD)); } bool allnav = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = allnav; long head = DepartmentService.GetCurrentHead(deptId); Employee h = EmployeeDAO.GetEmployeeById(head); ViewData["currentHead"] = h; if (timeErr) { ViewData["delegated"] = false; } else { ViewData["delegated"] = true; } return(View()); } else if (delegatedhead != null && d.Employee == null) { EmailNotification notice = new EmailNotification(); long head = DepartmentService.GetCurrentHead(deptId); Employee MailReceiver = EmployeeDAO.GetEmployeeById(head); notice.ReceiverMailAddress = MailReceiver.Email; DelegateService.DelegateToPreviousHead(deptId); Task.Run(() => emailService.SendMail(notice, EmailTrigger.ON_REMOVED_DEPT_HEAD)); List <Employee> emps = RepresentativeService.GetEmployeesByDepartment(deptId); ViewData["employees"] = emps; ViewData["delegated"] = false; bool show = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = show; return(View()); } else { ViewData["delegated"] = false; return(View()); } }
public RepresentativesController(RepresentativeService representativeService) { _representativeService = representativeService; }