// public List<Coupon> GetCouponByCouponCode(MandrillAccount MandrillAccount) //{ // List<MandrillAccount> res = new List<MandrillAccount>(); // try // { // //Creates a database connection and opens up a session // using (NHibernate.ISession session = SessionFactory.GetNewSession()) // { // //After Session creation, start Transaction. // using (NHibernate.ITransaction transaction = session.BeginTransaction()) // { // //Proceed action, to get coupon detail by coupon code. // res = session.CreateQuery("from Coupon u where u.CouponCode = : couponCode") // .SetParameter("couponCode", MandrillAccount.CouponCode) // .List<Coupon>().ToList<Coupon>(); // }//End transaction // }//End session // } // catch (Exception ex) // { // Console.WriteLine("Error : " + ex.StackTrace); // } // return res; //} /// <GetCouponByCouponId> /// Get the coupon detail by coupon Id. /// </summary> /// <param name="coupon">Set coupon value in a coupon Property Class and Pass the Object of coupon Class as a paremeter.(SocioBoard.Domain.Admin).</param> /// <returns>coupon values in the list of coupon properties classes.(List<Domain.Coupon>) </returns> public MandrillAccount GetMandrillAccountById(MandrillAccount MandrillAccount) { //Coupon res = null; List<MandrillAccount> res = new List<MandrillAccount>(); MandrillAccount objMandrillAccount = new MandrillAccount(); try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to get coupon detail by coupon id. res = session.CreateQuery("from MandrillAccount where Id= : id") .SetParameter("id", MandrillAccount.Id) .List<MandrillAccount>().ToList<MandrillAccount>(); }//End transaction }//End session objMandrillAccount = res[0]; } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return objMandrillAccount; }
protected void btnSave_Click(object sender, EventArgs e) { try { MandrillAccountRepository objMandrillAccountRepository = new MandrillAccountRepository(); MandrillAccount objMandrillAccount = new MandrillAccount(); objMandrillAccount.Id = (Guid.Parse(Request.QueryString["Id"].ToString())); objMandrillAccount.UserName = txtUsername.Text; objMandrillAccount.Password = txtpassword.Text; objMandrillAccount.Status = ddlStatus.SelectedValue; objMandrillAccount.Status = ddlStatus.SelectedValue; if (objMandrillAccountRepository.GetMandrillAccountByStatus(objMandrillAccount).Count < 1 || objMandrillAccountRepository.GetMandrillAccountByStatus(objMandrillAccount).Count == 0) { objMandrillAccountRepository.UpdateMandrillAccount(objMandrillAccount); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Modified Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Coupon Already Exist');", true); } } catch (Exception Err) { logger.Error(Err.Message); Response.Write(Err.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (Session["AdminProfile"] == null) //{ // Response.Redirect("Default.aspx"); //} if (Request.QueryString["Id"] != null) { try { //NewsRepository objNewsRepo = new NewsRepository(); //News news = objNewsRepo.getNewsDetailsbyId(Guid.Parse(Request.QueryString["Id"].ToString())); MandrillAccountRepository objMandrillAccountRepository = new MandrillAccountRepository(); MandrillAccount objMandrillAccount = new MandrillAccount(); objMandrillAccount.Id = (Guid.Parse(Request.QueryString["Id"].ToString())); MandrillAccount lstMandrillAccount = objMandrillAccountRepository.GetMandrillAccountById(objMandrillAccount); txtUsername.Text = lstMandrillAccount.UserName; txtpassword.Text = lstMandrillAccount.Password; ddlStatus.SelectedValue = lstMandrillAccount.Status; } catch (Exception ex) { logger.Error(ex.Message); } } } }
public string Add(MandrillAccount MandrillAccount) { string res = null; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to add new row. session.Save(MandrillAccount); transaction.Commit(); res = "Added"; }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
public List<MandrillAccount> GetMandrillAccountByMandrillUsernamePassword(MandrillAccount MandrillAccount) { //Coupon res = null; List<MandrillAccount> res = new List<MandrillAccount>(); try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to get coupon detail by coupon id. res = session.CreateQuery("from MandrillAccount where UserName= : uname and Password=:pwd") .SetParameter("uname", MandrillAccount.UserName) .SetParameter("pwd", MandrillAccount.UserName) .List<MandrillAccount>().ToList<MandrillAccount>(); }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
public int UpdateMandrillAccount(MandrillAccount MandrillAccount) { int res = 0; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to update existing data by coupon id. res = session.CreateQuery("Update MandrillAccount set UserName=:username,Password=:pwd,Status=:status where Id = :id") .SetParameter("id", MandrillAccount.Id) .SetParameter("username", MandrillAccount.UserName) .SetParameter("pwd", MandrillAccount.Password) .SetParameter("status", MandrillAccount.Status) .ExecuteUpdate(); transaction.Commit(); }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }