public ActionResult Query() { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var sql = "SELECT Ren.Id AS 'RenewalId', Reg.EstablishmentName, Ren.[Date], Ren.RenewalType_Id AS 'RenewalTypeId', Ren.Amount AS 'AmountDue', IFNULL(TR.TotalPaid, 0) AS 'TotalPaid', Ren.Amount - IFNULL(TR.TotalPaid, 0) AS 'Balance' FROM Renewal Ren LEFT JOIN (SELECT Renewal_Id, COUNT(Renewal_Id), SUM(Amount) AS 'TotalPaid' FROM [Transaction] GROUP BY Renewal_Id) AS TR ON Ren.Id = TR.Renewal_Id JOIN Registration Reg ON Ren.Registration_id = Reg.Id"; var payments = from x in session.CreateSQLQuery(sql).DynamicList() select new { RenewalId = x.Id, x.EstablishmentName, x.Date, x.RenewalTypeId, x.AmountDue, x.TotalPaid, x.Balance }; } } return(Content("abc")); }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { Permission entity; if (id == 0) { entity = new Permission(); } else { // collect objects var data = new List <Permission>(session.CreateCriteria(typeof(Permission)).List <Permission>()); // collect single object entity = data.FirstOrDefault(x => x.Id == id); } // trim excess if (entity != null) { //if (entity.Registrations != null) entity.Registrations = null; } // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(entity)); } } }
protected void vazgec_Click(object sender, EventArgs e) { var isession = NHibernateHelper.CreateSessionFactory(); using (var session = isession.OpenSession()) { var query = from yeniFirsatlar in session.Query <yeniFirsatlar>() where yeniFirsatlar.id.ToString() == hdnGidelecekFirsatId.Value select yeniFirsatlar; var firsat = query.ToList(); foreach (var item in firsat) { System.Diagnostics.Debug.WriteLine(item.id); var kisiSayisi = Int32.Parse(item.kisiSayisi); kisiSayisi++; item.kisiSayisi = kisiSayisi.ToString(); yeniFirsatlarController.update(item); } var updateQuery = session.CreateQuery("Update firsatLog set firsatdurumu = 'Gitmekten Vazgecti' where uyetcno =:uyeTcNo and firsatid =:firsatId "); updateQuery.SetParameter("firsatId", hdnGidelecekFirsatId.Value); updateQuery.SetParameter("uyeTcNo", services.uyeService.uye.tcNo); updateQuery.ExecuteUpdate(); } }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { /* * var registrationList = new List<Registration>(session.CreateCriteria(typeof(Registration)).List<Registration>()); * * var registration = registrationList.FirstOrDefault(x => x.Id == id); * * if (registration != null) * { * var registrationServices = registration.Services; * * var rowData = * from x in registrationServices * select new * { * serviceName = x. Description * }; * } * else * { * * } * */ return(WebApiHelper.ObjectToHttpResponseMessage("")); } } }
public HttpResponseMessage Get() { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { // collect objects var sqlPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/sql/rating.txt"); var sql = System.IO.File.ReadAllText(sqlPath); var data = from x in session.CreateSQLQuery(sql).DynamicList() select new { x.RegistrationId, x.EstablishmentName, x.NumberOfQuestions, x.TotalOfRatings }; // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(data)); } } }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var sql = System.IO.File.ReadAllText(_sqlPath); var payments = from x in session.CreateSQLQuery(sql).DynamicList() where x.RenewalId.Equals(id) select new { x.RenewalId, x.CacNumber, x.EstablishmentName, x.Date, x.RenewalTypeId, x.AmountDue, x.TotalPaid, x.Balance }; var stringResult = JsonConvert.SerializeObject(payments); return(StringToJsonActionResult(stringResult)); } } }
public HttpResponseMessage Get() { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { // collect objects var data = session.CreateCriteria(typeof(User)).List <User>(); data.ForEach(user => { if (user.State != null) { user.State.Locations = null; } if (user.Roles != null) { user.Roles.ForEach(role => role.Users = null); } }); // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(data)); } } }
public HttpResponseMessage Post(TypeOfEstablishment entity) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { TypeOfEstablishment typeOfEstablishment; if (entity.Id == 0) { typeOfEstablishment = new TypeOfEstablishment(); } else { var typeOfEstablishments = new List <TypeOfEstablishment>(session.CreateCriteria(typeof(TypeOfEstablishment)).List <TypeOfEstablishment>()); typeOfEstablishment = typeOfEstablishments.First(x => x.Id == entity.Id); } typeOfEstablishment.Name = entity.Name; typeOfEstablishment.Description = entity.Description; typeOfEstablishment.Staffings = entity.Staffings; session.SaveOrUpdate(typeOfEstablishment); transaction.Commit(); // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(entity)); } } }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { List <RolePermission> entity; if (id == 0) { entity = new List <RolePermission>(); } else { // collect objects var data = new List <RolePermission>(session.CreateCriteria(typeof(RolePermission)).List <RolePermission>()); // collect single object entity = data.Where(x => x.Role.Id == id).ToList(); } // trim excess entity.ForEach(x => { if (x.Role != null) { x.Role.Users = null; } }); // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(entity)); } } }
public ActionResult Establishment(EstablishmentSearch search) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var registrations = new List <Registration>(session.CreateCriteria(typeof(Registration)).List <Registration>()); if (!String.IsNullOrEmpty(search.EstablishmentName)) { registrations = registrations.Where(s => s.EstablishmentName.ToLower().Contains(search.EstablishmentName.ToLower())).ToList(); } if (!String.IsNullOrEmpty(search.PhermcRegistrationNumber)) { registrations = registrations.Where(s => s.PhermcRegistrationNumber.ToLower().Contains(search.PhermcRegistrationNumber.ToLower())).ToList(); } if (!String.IsNullOrEmpty(search.CacNumber)) { registrations = registrations.Where(s => s.CacNumber.ToLower().Contains(search.CacNumber.ToLower())).ToList(); } if (!String.IsNullOrEmpty(search.Location)) { registrations = registrations.Where(s => s.CacNumber.ToLower().Contains(search.Location.ToLower())).ToList(); } registrations = registrations.Where(s => s.RegistrationDate >= search.RegistrationDateFrom.DayMin()).ToList(); if (search.RegistrationDateTo.Equals(DateTime.MinValue)) { registrations = registrations.Where(s => s.RegistrationDate <= DateTime.MaxValue).ToList(); } else { registrations = registrations.Where(s => s.RegistrationDate <= search.RegistrationDateTo.DayMax()).ToList(); } /* * registrations = registrations.Where(s => s.LastRenewalDate >= search.LastRenewalDateFrom.DayMin()).ToList(); * * if (search.LastRenewalDateTo.Equals(DateTime.MinValue)) * { * registrations = registrations.Where(s => s.LastRenewalDate <= DateTime.MaxValue).ToList(); * } * else * { * registrations = registrations.Where(s => s.LastRenewalDate <= search.LastRenewalDateTo.DayMax()).ToList(); * }*/ registrations.ForEach(x => { //if (x.State != null) x.State.Locations = null; }); return(Content(WebApiHelper.ObjectToJsonString(registrations), "application/json")); } } }
protected void BtnGonder_Click(object sender, EventArgs e) { string enteredTcNo = String.Format("{0}", Request.Form["tcNo"]); string enteredSifre = String.Format("{0}", Request.Form["sifre"]); var isession = NHibernateHelper.CreateSessionFactory(); using (var session = isession.OpenSession()) { var query = from yeniUyeKayit in session.Query <yeniUyeKayit>() where yeniUyeKayit.tcNo == enteredTcNo && yeniUyeKayit.sifre == enteredSifre select yeniUyeKayit; var uyeler = query.ToList(); foreach (var item in uyeler) { System.Diagnostics.Debug.WriteLine(3); System.Diagnostics.Debug.WriteLine(item.tcNo + "sifre " + item.sifre + "isimsoyisim " + item.isimSoyisim + "email" + item.email + "telno" + item.telNo); uyeService.uye = item; } if (uyeler.Count == 0) { this.ikaz.InnerHtml = "BILGILERINIZI YANLIS GIRDINIZ"; this.tcNo.Style["background-color"] = " red"; this.sifre.Style["background-color"] = "red"; } else { Response.Redirect("uyeAnasayfa.aspx"); } } }
protected void Unnamed1_Click(object sender, EventArgs e) { var isession = NHibernateHelper.CreateSessionFactory(); if (hdnFirsatTuru.Value == "null" && hdnMahalle.Value != "null") { listelemeTuru = "mahalle"; setList(); hdnFirsatTuru.Value = "null"; hdnMahalle.Value = "null"; } else if (hdnFirsatTuru.Value != "null" && hdnMahalle.Value == "null") { listelemeTuru = "firsatTuru"; setList(); hdnFirsatTuru.Value = "null"; hdnMahalle.Value = "null"; } else if (hdnFirsatTuru.Value != "null" && hdnMahalle.Value != "null") { listelemeTuru = "ikiside"; setList(); hdnFirsatTuru.Value = "null"; hdnMahalle.Value = "null"; } else { System.Diagnostics.Debug.WriteLine("secim yap"); setList(); hdnFirsatTuru.Value = "null"; hdnMahalle.Value = "null"; } }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { // collect objects var dataList = new List <User>(session.CreateCriteria(typeof(User)).List <User>()); // collect single object var dataEntry = dataList.FirstOrDefault(x => x.Id == id); // trim excess if (dataEntry != null) { if (dataEntry.State != null) { dataEntry.State.Locations = null; } if (dataEntry.Roles != null) { dataEntry.Roles.ForEach(role => role.Users = null); } } // return as HttpResponseMessage return(WebApiHelper.ObjectToHttpResponseMessage(dataEntry)); } } }
public HttpResponseMessage Get(int id) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var registrations = new List <Registration>(session.CreateCriteria(typeof(Registration)).List <Registration>()); var registration = registrations.FirstOrDefault(x => x.Id == id); var staffings = session.CreateCriteria(typeof(Staffing)).List <Staffing>(); var services = session.CreateCriteria(typeof(Service)).List <Service>(); if (registration == null) { registration = new Registration(); foreach (var service in services) { registration.RegistrationServices.Add(new RegistrationService { Registration = registration, Selected = false, Service = service }); } } else { // Services foreach (var service in services) { if (registration.RegistrationServices.FirstOrDefault(x => x.Service.Id == service.Id) == null) { var rs = new RegistrationService { Registration = registration, Service = service, Selected = false }; registration.RegistrationServices.Add(rs); } } } // trim excess if (registration.Category != null) { if (registration.Category.Costings != null) { registration.Category.Costings = null; } } return(WebApiHelper.ObjectToHttpResponseMessage(registration)); } } }
public ActionResult Payment(PaymentSearch search) { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var payments = session.CreateCriteria(typeof(Transaction)).List <Transaction>(); if (!string.IsNullOrEmpty(search.PaymentMethod)) { var paymentMethodId = Convert.ToInt32(search.PaymentMethod); payments = payments.Where(s => s.PaymentType.Id.Equals(paymentMethodId)).ToList(); } if (!string.IsNullOrEmpty(search.ReceivedByName)) { payments = payments.Where(s => s.ReceivedBy.Username.ToLower().Contains(search.ReceivedByName.ToLower())).ToList(); } if (!string.IsNullOrEmpty(search.EstablishmentName)) { payments = payments.Where(s => s.Renewal.Registration.EstablishmentName.ToLower().Contains(search.EstablishmentName.ToLower())).ToList(); } payments = payments.Where(s => s.Date >= search.CreatedFrom).ToList(); if (search.CreatedTo.Equals(DateTime.MinValue)) { payments = payments.Where(s => s.Date <= DateTime.MaxValue).ToList(); } else { payments = payments.Where(s => s.Date <= search.CreatedTo).ToList(); } var jsonResult = from x in payments select new { Search = x /*Id = x.Id, * Created = x.Date, * PaymentMethod = x.PaymentType.Name, * ReceivedFrom = x.ReceivedBy, * ReceivedByName = x.ReceivedBy.Username, * x.Amount, * x.Renewal.Registration.EstablishmentName*/ }; return(Json(jsonResult)); } } }
public ActionResult<IEnumerable<Tarefa>> Get() { List<Tarefa> tarefas; var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { tarefas = session.Query<Tarefa>().ToList(); // Querying to get all the books } return tarefas; }
public ActionResult Enquiry(PaymentSearch search) { var sqlPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/sql/payments.txt"); using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var sql = System.IO.File.ReadAllText(sqlPath); var data = from x in session.CreateSQLQuery(sql).DynamicList() select new { x.Id, x.ReceivedFrom, x.Date, x.Amount, x.PaymentType, x.TransactionType, x.Renewal_id, x.Username, x.EstablishmentName }; var enquirySearchList = new List <EnquirySearch>(); if (data.Any()) { foreach (var d in data) { var enquirySearch = new EnquirySearch { Id = d.Id, ReceivedFrom = d.ReceivedFrom, Date = d.Date, Amount = d.Amount, PaymentType = d.PaymentType, TransactionType = d.TransactionType, ReceivedBy = d.Username, EstablishmentName = d.EstablishmentName }; enquirySearchList.Add(enquirySearch); } } var jsonResult = from x in enquirySearchList select x; return(Json(jsonResult)); } } }
public ActionResult<IEnumerable<Tarefa>> GetByUsuario(Guid id) { List<Tarefa> tarefas; var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { tarefas = session.Query<Tarefa>().Where(x => x.Responsavel.Id == id).ToList(); } return tarefas; }
public HttpResponseMessage Get() { using (var session = NHibernateHelper.CreateSessionFactory()) { using (var transaction = session.BeginTransaction()) { var registrations = session.CreateCriteria(typeof(Registration)).List <Registration>(); return(WebApiHelper.ObjectToHttpResponseMessage(registrations)); } } }
public ActionResult<Tarefa> Get(Guid id) { List<Tarefa> tarefa; var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { tarefa = session.Query<Tarefa>().ToList(); // Querying to get all the books } return tarefa.First(x => x.Id == id); }
public void Post(Tarefa tarefa) { var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(new Tarefa(tarefa.Descricao, tarefa.Concluido, tarefa.Responsavel)); transaction.Commit(); } } }
public void Put(Tarefa tarefa) { var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { using (var transaction = session.BeginTransaction()) { session.Update(tarefa); transaction.Commit(); } } }
public static void update(yeniFirsatlar firsat) { var isession = NHibernateHelper.CreateSessionFactory(); using (var session = isession.OpenSession()) { using (var trans = session.BeginTransaction()) { session.Update(firsat); trans.Commit(); } } }
public ActionResult <IEnumerable <Usuario> > Get() { List <Usuario> usuarios; var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { usuarios = session.Query <Usuario>().ToList(); // Querying to get all the books } return(usuarios); }
public ActionResult <Usuario> Get(Guid id) { List <Usuario> usuario; var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { usuario = session.Query <Usuario>().ToList(); // Querying to get all the books } return(usuario.First(x => x.Id == id)); }
public void Post(Usuario usuario) { var sessionFactory = NHibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(usuario); transaction.Commit(); } } }
public static void add(firsatLog log) { var isession = NHibernateHelper.CreateSessionFactory(); using (var session = isession.OpenSession()) { using (var trans = session.BeginTransaction()) { session.SaveOrUpdate(log); trans.Commit(); } } }
public ActionResult Index() { using (var s = NHibernateHelper.CreateSessionFactory()) { using (var t = s.BeginTransaction()) { var r1 = s.CreateCriteria(typeof(Registration)).List <Registration>(); var r = r1.FirstOrDefault(x => x.Id >= 1); return(View(r)); } } }
static void Main() { System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; Assembly ass = Assembly.Load("Toyz4net.App"); String cfgName = "Toyz4net.App.SQLite.cfg.xml"; NHibernateHelper.CreateCfg(ass, cfgName, Gobal.LOCAL_DB_CS); NHibernateHelper.CreateSessionFactory(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public static void add(yeniUyeKayit uye) { var isession = NHibernateHelper.CreateSessionFactory(); using (var session = isession.OpenSession()) { using (var trans = session.BeginTransaction()) { session.SaveOrUpdate(uye); trans.Commit(); } } }