public HttpResponseMessage GetAllDepartments() { var repo = new DepartmentsRepository(); var departmentList = repo.GetAll(); return(Request.CreateResponse(HttpStatusCode.OK, departmentList)); }
protected void Button2_Click(object sender, EventArgs e) { try { List <int> selectedRows = new List <int>(); foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox2") as CheckBox).Checked == true) { selectedRows.Add(gvr.Cells[0].Text.ToInt()); } } if (selectedRows.Count > 0) { DepartmentsRepository dir = new DepartmentsRepository(); dir.DeleteDepartment(selectedRows); LoadDepartmentData(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green); } } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDeleteFailed, Color.Red); } }
public void DeleteDepartments(int id) { DepartmentsRepository departmentsRepository = new DepartmentsRepository(); Departments obj = departmentsRepository.PrintOne(id); departmentsRepository.Delete(obj); }
private void SendEmail(string confirmed_canceled) { string date = ParentMeetingDateTimePicker.Value.ToShortDateString(); string time = TimeComboBox.Text; string SchoolMail = "*****@*****.**"; string SchoolName = "Skola"; string SchoolMailPassword = "******"; int TeacherId = CurrentTeacher.Id; int DepartmentId = DepartmentsRepository.GetIdByTeacherId(TeacherId); string StudentIds = StudentRepository.GetStudentIds(DepartmentId); string[] parts = StudentIds.Split(','); Email email = new Email(); for (int i = 0; i < parts.Length; i++) { Parent CurrentParent = ParentRepository.GetParentByStudentId(int.Parse(parts[i])); string currentParentEmail = CurrentParent.Email; string currentParentName = CurrentParent.Name; string message = "Poštovani " + CurrentParent.Name + " " + CurrentParent.Surname + "\n" + "Obavještavam Vas da je" + " " + confirmed_canceled + " " + "roditeljski sastanak dana " + date + " u " + time + "\n" + "Nastavnik : " + CurrentTeacher.Name + " " + CurrentTeacher.Surname ; email.SendEmailInBackground(SchoolMail, SchoolName, SchoolMailPassword, currentParentEmail, currentParentName, message); } MessageBox.Show("Roditelji su uspješno obaviješteni"); }
private void AddDepartmentAndClassTeacherButton_Click(object sender, EventArgs e) { if (DepartmentNumberTextBox.Text.Length == 0) { Warning(); } else { string[] parts = GetCurrentClassTeacher().Split('-'); string name = parts[0]; string surname = parts[1]; int TeachersId = TeacherRepository.GetIdByName(name, surname); int ClassNumber = GetCurrentClassNumber(); int ClassesId = ClassesRepository.GetIdByNumber(ClassNumber); try { int Title = int.Parse(DepartmentNumberTextBox.Text); bool isDepartmentAdded = DepartmentsRepository.AddDepartment(Title, TeachersId, ClassesId); if (isDepartmentAdded == true) { PopulateDepartmentsComboBox(); DepartmentNumberTextBox.Text = ""; } } catch (Exception) { MessageBox.Show("Molimo unesite broj odjeljenja"); } } }
private void PopulateDepartmentsComboBox() { string DepartmentQuery = DepartmentsRepository.GetQuery(); string SectionsQuery = SectionsRepository.GetQuery(); Lists.FillDropDownList2(SectionsQuery, "Description", DepartmentQuery, "Title", DepartmentComboBox); }
public HttpResponseMessage ViewDepartmentEmployees(string DepartmentID) { var repository = new DepartmentsRepository(); var result = repository.ListDepartmentEmployees(DepartmentID); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage GetSingleDepartment(int departmentId) { var repo = new DepartmentsRepository(); var departmentDetails = repo.GetSingleDepartment(departmentId); return(Request.CreateResponse(HttpStatusCode.OK, departmentDetails)); }
public HttpResponseMessage GetDepartmentList() { var repository = new DepartmentsRepository(); var result = repository.ListAllDepartments(); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public IActionResult Index() { var repo = new DepartmentsRepository(); var products = repo.GetAllDepartments(); return(View(products)); }
public List <Departments> GetAllDepartments() { DepartmentsRepository departmentsRepository = new DepartmentsRepository(); var departments = departmentsRepository.PrintAll(); return(departments); }
public DataAccess() { _context = new UniversityDbContext(); _coursesRepository = new CoursesRepository(_context); _departmentsRepository = new DepartmentsRepository(_context); _studentsRepository = new StudentsRepository(_context); _enrollemntsRepository = new EnrollementsRepository(_context); }
public ListDataService() { // Initialize the repositories RolesRepository = new RolesRepository(); DepartmentsRepository = new DepartmentsRepository(); UsersRepository = new UsersRepository(); SemestersRepository = new SemestersRepository(); DaysOfWeekRepository = new DaysOfWeekRepository(); }
public void AddDepartments(Departments entity) { DepartmentsRepository departmentsRepository = new DepartmentsRepository(); InstructorRepository instructorRepository = new InstructorRepository(); Instructor instructor = instructorRepository.PrintOne(entity.InstructorID); entity.Instructor = instructor; departmentsRepository.Add(entity); }
public void AddCourses(Courses entity) { CoursesRepository courseRepository = new CoursesRepository(); DepartmentsRepository departmentsRepository = new DepartmentsRepository(); Departments departments = departmentsRepository.PrintOne(entity.DepartmentID); entity.Departments = departments; courseRepository.Add(entity); }
public DepartmentsViewModel ReadOneDepartment(int _id) { DepartmentsEntity department = new DepartmentsRepository().ReadOne(_id); DepartmentsViewModel department_vm = new DepartmentsViewModel(); department_vm.Id = department.Id; department_vm.Name = department.Name; return(department_vm); }
public override void InitParams() { dbSet = _context.Departments; r = new DepartmentsRepository(_context); model1 = new Department { Name = "AAA" }; model2 = new Department { Name = "BBB" }; }
public IActionResult ViewDepartment(int id) { var repo = new DepartmentsRepository(); var depo = repo.ViewDepartment(id); if (depo == null) { return(View("Department not found")); } return(View(depo)); }
public HttpResponseMessage AddNewDepartment(DepartmentsDto department) { var repository = new DepartmentsRepository(); var result = repository.Create(department); if (result) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not add new department")); }
public void loadform() { DepartmentsRepository etr = new DepartmentsRepository(); DataTable dt = etr.GetAllDepartment(); ddldepartment.Items.Clear(); foreach (DataRow dr in dt.Rows) { ddldepartment.Items.Add(new ListItem(dr["DepartmentTitle"].ToString(), dr["DepartmentID"].ToString())); } }
public HttpResponseMessage CreateDepartment(DepartmentsDto department) { var repo = new DepartmentsRepository(); var newDepartment = repo.CreateDepartment(department); if (newDepartment) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Sorry, your new department cannot be created at this time.")); }
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { lblmessage.Text = ""; if (txtsearch.Text.Length > 0) { if (DropDownList1.SelectedValue == "0") { try { DepartmentsRepository dir = new DepartmentsRepository(); Session["Departmentdatafindid"] = dir.Searchdepid(txtsearch.Text.ToInt()); GridView1.DataSource = Session["Departmentdatafindid"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", dir.DepartmanetCount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["Departmentdatafindid"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } if (DropDownList1.SelectedValue == "1") { try { DepartmentsRepository dir = new DepartmentsRepository(); Session["Departmentdatafindtitle"] = dir.SearchTitle(txtsearch.Text.ToString()); GridView1.DataSource = Session["Departmentdatafindtitle"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", dir.DepartmanetCount().ToString(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["Departmentdatafindtitle"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red); lblrecordcount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount); } } } else { LoadDepartmentData(); } }
public void GetItemTest() { //_context.Departments.RemoveRange(_context.Departments); var repo = new DepartmentsRepository(_context); var item = new Department { Name = "Security Department" }; repo.AddItem(item); int Id = _context.Departments.FirstOrDefault(x => x.Name == item.Name).Id; Assert.AreEqual(item.Name, repo.GetItem(Id).Name); _context.Departments.Remove(item); }
public void AddItemTest() { //_context.Departments.RemoveRange(_context.Departments); var repo = new DepartmentsRepository(_context); var item = new Department { Name = "Department999" }; repo.AddItem(item); string name = _context.Departments.FirstOrDefault(x => x.Name == item.Name).Name; Assert.AreEqual(item.Name, name); _context.Departments.Remove(item); }
public void LoadDepartmentData() { DepartmentsRepository dir = new DepartmentsRepository(); Session["DepartmentData"] = dir.GetAllDepartment(); GridView1.DataSource = Session["DepartmentData"]; GridView1.DataBind(); lblrecordcount.Text = string.Format("{0} : {1}", dir.DepartmanetCount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount); lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["DepartmentData"] as DataTable).Rows.Count.ToString().ToFarsiNumber(), Resources.DashboardText.SelectRecordCount); }
public IEnumerable <DepartmentsViewModel> ReadAllDepartments() { IEnumerable <DepartmentsEntity> departments = new DepartmentsRepository().ReadAll(); List <DepartmentsViewModel> departments_vm = new List <DepartmentsViewModel>(); foreach (DepartmentsEntity _s in departments) { departments_vm.Add(new DepartmentsViewModel { Id = _s.Id, Name = _s.Name }); } return(departments_vm); }
static Unit() { _context = new MyAppDbContext("MyAppConnStr"); DepartmentsRepository = new DepartmentsRepository(_context); TeachersRepository = new TeachersRepository(_context); SubjectsRepository = new SubjectsRepository(_context); SpecialitiesRepository = new SpecialitiesRepository(_context); GroupsRepository = new GroupsRepository(_context); PhonesRepository = new PhonesRepository(_context); StudentsRepository = new StudentsRepository(_context); AudiencesRepository = new AudiencesRepository(_context); AudLectRepository = new AudLectRepository(_context); LectionsRepository = new LectionsRepository(_context); MarksRepository = new MarksRepository(_context); TeachSubjRepository = new TeachSubjRepository(_context); }
public void ChangeItemTest() { //_context.Departments.RemoveRange(_context.Departments); var repo = new DepartmentsRepository(_context); var item = new Department { Name = "Department806" }; repo.AddItem(item); int Id = _context.Departments.FirstOrDefault(x => x.Name == item.Name).Id; var newitem = repo.GetItem(Id); newitem.Name = "Department807"; repo.ChangeItem(newitem); Assert.AreEqual(newitem.Name, _context.Departments.FirstOrDefault(x => x.Name == newitem.Name).Name); _context.Departments.Remove(item); }
private async Task AuthRequest(object sender, EventArgs e) { var context = ((HttpApplication)sender).Context; if (context.Request.AppRelativeCurrentExecutionFilePath.StartsWith("~/signalR-webEvents", StringComparison.OrdinalIgnoreCase)) { await Task.Factory.StartNew(() => { //var y = (IDepartmentsService)WebApiApplication.Kernel.GetService(typeof(IDepartmentsService)); var y = new DepartmentsRepository(new DataContext(), new StandardIsolation()); var z = new AzureRedisCacheProvider(); AuthTokenMessageHandler.AuthAndSetPrinciple(z, y, context.Request.Headers, new HttpContextWrapper(context)); }); } return; }
/// <summary> /// Controller Initialization /// </summary> /// <param name="emptyEmployees">Creates a context without any departments</param> /// <returns></returns> private EmployeesController CreateController(bool emptyDepartments = false, bool emptyEmployees = false, [CallerMemberName] string databaseName = "") { IHost host = Host.CreateDefaultBuilder().Build(); ILogger <EmployeesController> logger = host.Services.GetRequiredService <ILogger <EmployeesController> >(); DbContextOptions <VogContext> contextOptions = new DbContextOptionsBuilder <VogContext>().UseInMemoryDatabase(databaseName: databaseName).Options; VogContext context = new VogContext(contextOptions); if (!emptyDepartments) { context.Departments.Add(new Department { Id = 1, Name = "Ecology Department", Address = "1865 Reserve St Campbellford, ON K0L 1L0" }); context.Departments.Add(new Department { Id = 2, Name = "Construction Department", Address = "2635 Hammarskjold Dr Burnaby, BC V5B 3C9" }); context.SaveChanges(); } if (!emptyEmployees) { context.Employees.Add(new Employee { Id = 1, DepartmentId = 1, FirstName = "Dan", LastName = "Loden", JobTitle = "Nature Inspector", MailingAddress = "4652 Bates Brothers Road Hilliard, OH 43026" }); context.Employees.Add(new Employee { Id = 2, DepartmentId = 1, FirstName = "Jennifer", LastName = "Evans", JobTitle = "Range Ecologist", MailingAddress = "4278 Walnut Avenue Newark, NJ 07102" }); context.Employees.Add(new Employee { Id = 3, DepartmentId = 2, FirstName = "Teresa", LastName = "Hill", JobTitle = "Construction Equipment Technician", MailingAddress = "3789 Cook Hill Road Stamford, CT 06995" }); context.Employees.Add(new Employee { Id = 4, DepartmentId = 2, FirstName = "Shane", LastName = "Headrick", JobTitle = "Construction Equipment Operator", MailingAddress = "1020 Yoho Valley Road Golden, BC V0A 1H0" }); context.SaveChanges(); } DepartmentsRepository departmentsRepository = new DepartmentsRepository(context); DepartmentsService departmentsService = new DepartmentsService(departmentsRepository); EmployeesRepository employeesRepository = new EmployeesRepository(context); EmployeesService employeesService = new EmployeesService(employeesRepository); return(new EmployeesController(logger, employeesService, departmentsService)); }