public IEnumerable <string> Groups() { var repo = new NHGetAllRepository <School>(); var data = repo.GetAll(); return(data.Select(x => x.Name)); }
public IEnumerable <Volunteer> GetAll() { using (var repo = new NHGetAllRepository <Volunteer>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <Subject> GetAll() { using (var repo = new NHGetAllRepository <Subject>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <SchoolType> GetAll() { using (var repo = new NHGetAllRepository <SchoolType>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <string> CityTypes() { var repo = new NHGetAllRepository <CityType>(); var data = repo.GetAll(); return(data.Select(x => x.Name)); }
public ActionResult Edit(int id) { var attendee = new NHRepository <Attendee>().Get(id); if (attendee.Type == AttendeeType.Pupil) { List <School> schools; using (var repository = new NHGetAllRepository <School>()) { schools = repository.GetAll().ToList(); } ViewData["Schools"] = new SelectList(schools, "Id", "Name"); List <AcademicProgram> programs; using (var repository = new NHGetAllRepository <AcademicProgram>()) { programs = repository.GetAll().ToList(); } ViewData["Programs"] = new SelectList(programs, "Id", "Name"); var list = new AcademicProgram { Id = -1, Name = "не выбрано" }.AsEnumerable().Concat(programs).ToList(); ViewData["NullablePrograms"] = new SelectList(list, "Id", "Name"); var pupil = attendee as Pupil; return(View("EditPupil", pupil)); } return(View(attendee)); }
public IEnumerable <Department> GetAll() { using (var repo = new NHGetAllRepository <Department>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <Entity> GetAll() { using (var repo = new NHGetAllRepository <Entity>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <AcademicProgram> GetAll() { using (var repo = new NHGetAllRepository <AcademicProgram>()) { return(repo.GetAll().AsEnumerable()); } }
public IEnumerable <string> Volunteers() { var repo = new NHGetAllRepository <Volunteer>(); var data = repo.GetAll(); return(data.Select(x => x.FullName)); }
public IEnumerable <string> AcademicPrograms() { var repo = new NHGetAllRepository <AcademicProgram>(); var data = repo.GetAll(); return(data.Select(x => x.Name)); }
public ActionResult Add() { List <School> schools; using (var repository = new NHGetAllRepository <School>()) { schools = repository.GetAll().ToList(); } ViewData["Schools"] = new SelectList(schools, "Id", "Name"); List <AcademicProgram> programs; using (var repository = new NHGetAllRepository <AcademicProgram>()) { programs = repository.GetAll().ToList(); } ViewData["Programs"] = new SelectList(programs, "Id", "Name"); var list = new AcademicProgram { Id = -1, Name = "не выбрано" }.AsEnumerable().Concat(programs).ToList(); ViewData["NullablePrograms"] = new SelectList(list, "Id", "Name"); return(View()); }
public IEnumerable <string> ContactPersons() { var repo = new NHGetAllRepository <ContactPerson>(); var data = repo.GetAll(); return(data.Select(x => x.ContactInfo.FullName)); }
public IEnumerable <string> Departments() { var repo = new NHGetAllRepository <Department>(); var data = repo.GetAll(); return(data.Select(x => x.Name)); }
public IEnumerable<Group> GetAll() { using (var repo = new NHGetAllRepository<Group>()) { return repo.GetAll().AsEnumerable(); } }
public ActionResult School(int id = 0) { ViewBag.Edit = id != 0; List <Address> addresses; using (var repository = new NHGetAllRepository <Address>()) { addresses = repository.GetAll().ToList(); } var listAddress = (IEnumerable <SelectListItem>) new SelectList(addresses, "Id", "FullAddress"); List <SchoolType> types; using (var repository = new NHGetAllRepository <SchoolType>()) { types = repository.GetAll().ToList(); } var listType = (IEnumerable <SelectListItem>) new SelectList(types, "Id", "Name"); SchoolDto school = new SchoolDto(); if (id != 0) { using (var repository = new NHRepository <School>()) { var t = repository.Get(id); school = new SchoolDto() { Id = t.Id, Address = t.Addresses.ToList()[0].Id, Name = t.Name, Type = t.Type.Id }; } listAddress = addresses.Select(x => new SelectListItem() { Text = x.FullAddress, Selected = x.Id == school.Address, Value = x.Id.ToString() }); listType = types.Select(x => new SelectListItem() { Text = x.Name, Selected = x.Id == school.Type, Value = x.Id.ToString() }); } ViewData["Address"] = listAddress; ViewData["Type"] = listType; return(View(school)); }
public IEnumerable <Address> Addresses(int?index) { var repo = new NHGetAllRepository <Address>(); var data = repo.GetAll(); var ids = new NHGetAllRepository <School>().GetAll().Where(x => x.Id != index).SelectMany(x => x.Addresses.Select(xx => xx.Id)); return(data.Where(x => !ids.Contains(x.Id))); }
public ActionResult EditPupil(Pupil pupil, int school, IEnumerable <int> intrestingPrograms, IEnumerable <int> registrarionPrograms, int enterProgram) { List <School> schools; using (var repository = new NHGetAllRepository <School>()) { schools = repository.GetAll().ToList(); } ViewData["Schools"] = new SelectList(schools, "Id", "Name"); List <AcademicProgram> programs; using (var repository = new NHGetAllRepository <AcademicProgram>()) { programs = repository.GetAll().ToList(); } ViewData["Programs"] = new SelectList(programs, "Id", "Name"); var list = new AcademicProgram { Id = -1, Name = "не выбрано" }.AsEnumerable().Concat(programs).ToList(); ViewData["NullablePrograms"] = new SelectList(list, "Id", "Name"); IsValid = true; if (pupil.ContactInfo.FullName.IsNullOrEmpty()) { AddModelError("FullName", "Введите ФИО"); } if (!pupil.ContactInfo.Email.IsCorrectEmail()) { AddModelError("Email", "Неверный формат Email"); } if (!pupil.ContactInfo.PhoneNumber.IsCorrectPhone()) { AddModelError("PhoneNumber", "Неверный формат номера"); } if (pupil.YearOfGraduation <= 2010 || pupil.YearOfGraduation >= 2030) { AddModelError("Year", "Неверный формат года"); } if (!IsValid) { return(View()); } new PupilRepository().Update(pupil, school, intrestingPrograms, registrarionPrograms, enterProgram); return(RedirectToAction("Index")); }
public ActionResult AddExecution() { using (var repository = new NHGetAllRepository <Address>()) { var list = repository.GetAll().ToList(); ViewData["Addresses"] = new SelectList(list, "Id", "FullAddress"); } return(PartialView()); }
public IEnumerable <SimpleEntity> GetSimple() { var repo = new NHGetAllRepository <Volunteer>(); var data = repo.GetAll(); return(data.Select(x => new SimpleEntity() { Id = x.Id, View = x.FullName })); }
public IEnumerable <SimpleEntity> GetSimple() { var repo = new NHGetAllRepository <AcademicProgram>(); var data = repo.GetAll(); return(data.Select(x => new SimpleEntity() { Id = x.Id, View = x.Name })); }
public IEnumerable <SimpleEntity> GetSimple() { var repo = new NHGetAllRepository <Address>(); var data = repo.GetAll(); return(data.ToList().Select(x => new SimpleEntity() { Id = x.Id, View = x.FullAddress })); }
public IEnumerable <Region> GetAll(RegionArgs args) { using (var repo = new NHGetAllRepository <Region>()) { var query = repo.GetAll(); if (args.Country.IsNotEmpty()) { query = query.Where(x => x.Country.Name == args.Country); } return(query.AsEnumerable()); } }
public ActionResult Add(Event @event, IEnumerable <int> volunteers, IEnumerable <int> organizers, IEnumerable <int> lecturers, IEnumerable <int> departments) { using (var repository = new NHGetAllRepository <Volunteer>()) { var list = repository.GetAll().ToList(); ViewData["Volunteers"] = new SelectList(list, "Id", "Name"); } using (var repository = new NHGetAllRepository <Employee>()) { var list = repository.GetAll().ToList(); ViewData["Employees"] = new SelectList(list, "Id", "ContactInfo.FullName"); } using (var repository = new NHGetAllRepository <Department>()) { var list = repository.GetAll().ToList(); ViewData["Departments"] = new SelectList(list, "Id", "Name"); } if (@event.Name.IsNullOrEmpty() || @event.Info.IsNullOrEmpty()) { EventExecution.Clear(); return(View()); } @event.Volunteers = Parse <Volunteer>(volunteers).ToList(); @event.Volunteers = Parse <Volunteer>(organizers).ToList(); @event.Volunteers = Parse <Volunteer>(lecturers).ToList(); @event.Volunteers = Parse <Volunteer>(departments).ToList(); if (EventExecution != null) { @event.EventExecutions = ParseEventExecutions(EventExecution).ToList(); } using (var repository = new NHRepository <Event>()) { repository.Add(@event); } EventExecution.Clear(); return(RedirectToAction("Index")); }
public ActionResult Address(int id = 0) { ViewBag.Edit = id != 0; List <CityType> types; using (var repository = new NHGetAllRepository <CityType>()) { types = repository.GetAll().ToList(); } var list = (IEnumerable <SelectListItem>) new SelectList(types, "id", "Name"); AddressDto address = new AddressDto(); if (id != 0) { using (var repository = new NHRepository <Address>()) { var t = repository.Get(id); address = new AddressDto() { Id = t.Id, House = t.House, Street = t.Street.Name, Country = t.Country.Name, Region = t.Region.Name, CityType = t.CityType.Id, City = t.City.Name }; } list = types.Select(x => new SelectListItem() { Text = x.Name, Selected = x.Id == address.CityType, Value = x.Id.ToString() }); } ViewData["CityType"] = list; return(View(address)); }
public ActionResult Add() { using (var repository = new NHGetAllRepository <Volunteer>()) { var list = repository.GetAll().ToList(); ViewData["Volunteers"] = new SelectList(list, "Id", "Name"); } using (var repository = new NHGetAllRepository <Employee>()) { var list = repository.GetAll().ToList(); ViewData["Employees"] = new SelectList(list, "Id", "ContactInfo.FullName"); } using (var repository = new NHGetAllRepository <Department>()) { var list = repository.GetAll().ToList(); ViewData["Departments"] = new SelectList(list, "Id", "Name"); } return(View()); }
public ActionResult School(SchoolDto school) { List <Address> addresses; using (var repository = new NHGetAllRepository <Address>()) { addresses = repository.GetAll().ToList(); } var list = (IEnumerable <SelectListItem>) new SelectList(addresses, "Id", "FullAddress"); ViewData["Address"] = list; List <SchoolType> types; using (var repository = new NHGetAllRepository <SchoolType>()) { types = repository.GetAll().ToList(); } ViewData["Type"] = new SelectList(types, "Id", "Name"); ViewBag.Edit = school.Id != 0; if (school.Name.IsNullOrEmpty()) { ModelState.AddModelError("Name", "Поле не может быть пустым"); } if (school.Address == 0) { ModelState.AddModelError("Address", "Поле не может быть пустым"); } if (!ModelState.IsValid) { return(View(school)); } var session = NHibernateHelper.OpenSession(); using (var tx = session.BeginTransaction()) { var address = session.Query <Address>().First(x => x.Id == school.Address); var type = session.Query <SchoolType>().First(x => x.Id == school.Type); var entity = new School() { Id = school.Id, Name = school.Name, Addresses = new List <Address>() { address }, Type = type }; session.SaveOrUpdate(entity); tx.Commit(); } return(RedirectToAction("Index")); }
public ActionResult Address(AddressDto address) { List <CityType> types; using (var repository = new NHGetAllRepository <CityType>()) { types = repository.GetAll().ToList(); } var list = (IEnumerable <SelectListItem>) new SelectList(types, "Id", "Name"); ViewData["CityType"] = list; ViewBag.Edit = address.Id != 0; if (address.Country.IsNullOrEmpty()) { ModelState.AddModelError("Country", "Поле не может быть пустым"); } if (address.Region.IsNullOrEmpty()) { ModelState.AddModelError("Region", "Поле не может быть пустым"); } if (address.City.IsNullOrEmpty()) { ModelState.AddModelError("City", "Поле не может быть пустым"); } if (address.CityType == 0) { ModelState.AddModelError("CityType", "Поле не может быть пустым"); } if (address.Street.IsNullOrEmpty()) { ModelState.AddModelError("Street", "Поле не может быть пустым"); } if (address.House.IsNullOrEmpty()) { ModelState.AddModelError("House", "Поле не может быть пустым"); } if (!ModelState.IsValid) { return(View(address)); } var session = NHibernateHelper.OpenSession(); using (var tx = session.BeginTransaction()) { var country = session.Query <Country>().FirstOrDefault(x => x.Name == address.Country) ?? new Country() { Name = address.Country }; var region = session.Query <Region>().FirstOrDefault(x => x.Name == address.Region) ?? new Region() { Name = address.Region, Country = country }; var cityType = session.Query <CityType>().First(x => x.Id == address.CityType); var city = session.Query <City>().FirstOrDefault(x => x.Name == address.City) ?? new City() { Name = address.City, Region = region, CityType = cityType }; var street = session.Query <Street>().FirstOrDefault(x => x.Name == address.Street) ?? new Street() { Name = address.Street, City = city }; var entity = new Address() { Id = address.Id, House = address.House, Street = street, }; session.SaveOrUpdate(entity); tx.Commit(); } return(RedirectToAction("Index")); }