public static string Titlebar() { string title = ""; try { DateTime datetime = DateTime.Now; var hour = datetime.Hour; if (hour >= 18) { title = "Good Night" + "," + SingletonSession.Instance().getUsername().ToUpper(); } else if (hour >= 12) { title = "Good Afternoon" + "," + SingletonSession.Instance().getUsername().ToUpper(); } else { title = "Good Morning" + "," + SingletonSession.Instance().getUsername().ToUpper(); } } catch (Exception ex) { throw (ex); } return(title); }
public ViewResult EditAnnoun(ChordTab chordTab) { IRepository <ChordTab> chordTabs = new EntityRepository <ChordTab>(SingletonSession.getInstance().sess); ChordTab previousAnnoun = chordTabs.ReadById(chordTab.UID); previousAnnoun._Chord = SingletonSession.getInstance().sess.Merge(chordTab._Chord); using (ITransaction transaction = SingletonSession.getInstance().sess.BeginTransaction()) { DeletePhoto(HttpContext.Request.Form, previousAnnoun); foreach (var file in HttpContext.Request.Form.Files) { string path = hosting.WebRootPath + "/images/" + GenerateFileName(chordTab._Chord, file.FileName); using (var fileStream = new FileStream(path, FileMode.Create)) { file.CopyTo(fileStream); } Photos photo = new Photos(); photo.Name = GenerateFileName(chordTab._Chord, file.FileName); previousAnnoun._Photos.Add(photo); } chordTabs.Update(previousAnnoun); transaction.Commit(); } return(PersonalPage()); }
/// <summary> /// Страница объявления /// </summary> /// <param name="announID">id объявления</param> /// <returns>Представление, в которое передается объявление, полученное за б/д</returns> public ViewResult ChordCard(string announID) { IRepository <ChordTab> chordTabs = new EntityRepository <ChordTab>(SingletonSession.getInstance().sess); ChordTab chordTab = chordTabs.ReadById(Int32.Parse(announID)); return(View(chordTab)); }
/// <summary> /// Удаление песни /// </summary> /// <param name="chordTabId"></param> /// <returns></returns> public ViewResult DeleteAnnoun(string chordTabId) { IRepository <User> users = new EntityRepository <User>(SingletonSession.getInstance().sess); User user = users.ReadById(Int32.Parse(HttpContext.Session.GetString("userid"))); foreach (ChordTab a in user._ChordTab) { if (a.UID == Int32.Parse(chordTabId)) { user._ChordTab.Remove(a); a._User = null; foreach (Photos p in a._Photos) { string path = hosting.WebRootPath + "/images/" + p.Name; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } using (ITransaction transaction = SingletonSession.getInstance().sess.BeginTransaction()) { IRepository <ChordTab> chordTabs = new EntityRepository <ChordTab>(SingletonSession.getInstance().sess); chordTabs.Delete(a); transaction.Commit(); } break; } } return(PersonalPage()); }
public ViewResult SellingChord(ChordTab chordTab) { IRepository <User> users = new EntityRepository <User>(SingletonSession.getInstance().sess); User user = users.ReadById(Int32.Parse(HttpContext.Session.GetString("userid"))); if (ModelState.IsValid) { using (ITransaction transaction = SingletonSession.getInstance().sess.BeginTransaction()) { foreach (var file in HttpContext.Request.Form.Files) { string path = hosting.WebRootPath + "/images/" + GenerateFileName(chordTab._Chord, file.FileName); using (var fileStream = new FileStream(path, FileMode.Create)) { file.CopyTo(fileStream); } Photos photo = new Photos { Name = GenerateFileName(chordTab._Chord, file.FileName) }; chordTab._Photos.Add(photo); } user.AddChordTab(chordTab); users.Save(user); transaction.Commit(); } return(PersonalPage()); } ViewBag.Error = "Вы не заполнили один из полей!"; return(View()); }
public ViewResult SignUp(User newUser) { using (ITransaction transaction = SingletonSession.getInstance().sess.BeginTransaction()) { if (ModelState.IsValid) { IRepository <User> users = new EntityRepository <User>(SingletonSession.getInstance().sess); if (users.ReadByLogin(newUser.Login)) { newUser.Password = BCrypt.Net.BCrypt.HashPassword(newUser.Password); newUser.Avatar = "defaultavatar.png"; users.Save(newUser); transaction.Commit(); HttpContext.Session.SetString("userid", newUser.UID.ToString()); return(PersonalPage()); } else { ViewBag.Error = "Пользователь с таким логином уже существует"; return(View()); } } ViewBag.Error = "Вы не заполнили один из полей!"; return(View()); } }
public ViewResult Index() { IRepository <ChordTab> chordTab = new EntityRepository <ChordTab>(SingletonSession.getInstance().sess); List <ChordTab> chordTabs = chordTab.ReadAll(); SelectList style = new SelectList(chordTabs.Select(t => t._Chord.Style).Distinct()); ViewBag.Style = style; return(View("HomePage", chordTabs)); }
/// <summary> /// Персональная страница /// </summary> /// <returns>Представление, в которое передается пользователь, полученный из б/д</returns> public ViewResult PersonalPage() { if (HttpContext.Session.GetString("userid") == null) { return(SignUp()); } IRepository <User> users = new EntityRepository <User>(SingletonSession.getInstance().sess); User user = users.ReadById(Int32.Parse(HttpContext.Session.GetString("userid"))); return(View("PersonalPage", user)); }
public ViewResult Index(object obj) { IRepository <ChordTab> chordTab = new EntityRepository <ChordTab>(SingletonSession.getInstance().sess); List <ChordTab> chordTabs = chordTab.ReadAll(); SelectList styles = new SelectList(chordTabs.Select(t => t._Chord.Style).Distinct()); ViewBag.Style = styles; var style = HttpContext.Request.Form["style"]; chordTabs = chordTab.ReadByFilter(style); return(View("HomePage", chordTabs)); }
private void GoForLogin(string plantId) { if (!string.IsNullOrEmpty(plantId)) { Intent i = new Intent(this, typeof(LoginActivity)); StartActivity(i); //OverridePendingTransition(Resource.Animation.right_to_left, Resource.Animation.abc_fade_out); SingletonSession.Instance().setPlantID(plantId); } else { Helper.ShowToastMessage(this, Color.DarkRed, "Plant Is Empty..!!!", ToastLength.Short); } }
public ViewResult SignIn(User user) { IRepository <User> users = new EntityRepository <User>(SingletonSession.getInstance().sess); user = users.ReadByLoginAndPassword(user.Login, user.Password); if (user != null) { HttpContext.Session.SetString("userid", user.UID.ToString()); return(PersonalPage()); } ViewBag.Error = "Неверный логин или пароль!"; return(View()); }
public override void OnBackPressed() { try { var intent = new Intent(this, typeof(SitesActivity)); intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask); StartActivity(intent); SingletonSession.Instance().setPlantID(""); Finish(); } catch (System.Exception ex) { Helper.ShowToastMessage(this, Color.DarkRed, ex.Message, ToastLength.Short); } }
/// <summary> /// Точка подключения к б/д с последующим её обновлением /// </summary> /// <param name="configuration"></param> public Startup(IConfiguration configuration) { Configuration = configuration; var Config = Fluently.Configure(). Database( PostgreSQLConfiguration .Standard .ConnectionString($"Server=127.0.0.1;Port=5432;Database=favouritechord;User id=postgres;Password=1111;") .Dialect <PostgreSQLDialect>().ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <UserMap>()) .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true)) .BuildConfiguration(); ISessionFactory factory = Config.BuildSessionFactory(); ISession session = factory.OpenSession(); SingletonSession.getInstance(session); }
private async void Btnsign_Click(object sender, EventArgs e) { Dialog dialog = null; try { if (txtusername.Text != "" && txtPassword.Text != "") { if (CrossConnectivity.Current.IsConnected) { #region Loading Dialog LayoutInflater layoutInflater = LayoutInflater.From(this); View progressDialogBox = layoutInflater.Inflate(Resource.Layout.flashLayout, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.SetView(progressDialogBox); var progressBar1 = progressDialogBox.FindViewById <ProgressBar>(Resource.Id.ProgressBar01); var txtviewmessage = progressDialogBox.FindViewById <TextView>(Resource.Id.txtmessage); txtviewmessage.Text = "Please wait Loading..."; dialog = alertDialogBuilder.Create(); dialog.SetCanceledOnTouchOutside(false); dialog.SetCancelable(false); dialog.Show(); #endregion var login = new Login(SingletonSession.Instance().getPlantID(), txtusername.Text, txtPassword.Text, 123); HttpResponseMessage response = await login.LoggedIn(); if (response.ReasonPhrase == "OK") { var result = await response.Content.ReadAsStringAsync(); if (result.Contains("Success")) { SingletonSession.Instance().setUsername(txtusername.Text.ToString()); StartActivity(typeof(CategoryActivity)); //OverridePendingTransition(Resource.Animation.right_to_left,Resource.Animation.abc_fade_out); dialog.Hide(); dialog.Dismiss(); Helper.ShowToastMessage(this, Color.DarkGreen, "Login Successful...", ToastLength.Short); } else { dialog.Hide(); dialog.Dismiss(); txtusername.Text = string.Empty; txtPassword.Text = string.Empty; SingletonSession.Instance().setUsername(""); throw new AndroidRuntimeException("User ID or Password Wrong..."); } } else { dialog.Hide(); dialog.Dismiss(); throw new AndroidRuntimeException("Internal server Error..."); } } else { throw new AndroidRuntimeException("Check your internet connection and try again.."); } } else { throw new AndroidRuntimeException("Enter your User Id or Password ....."); } } catch (AndroidRuntimeException ex) { Helper.ShowToastMessage(this, Color.DarkRed, ex.Message, ToastLength.Short); } }