public ActionResult LozinkaSnimi(ProfilVM a) { Kupci db; db = ctx.Kupci.Where(o => o.KupacID == a.KupacID).FirstOrDefault(); if (a.PotvrdnaLozinka == null || a.Lozinka == null || a.StaraLozinka == null) { return(RedirectToAction("Index", new { ok = 1 })); } if (a.PotvrdnaLozinka == a.Lozinka && (WebHelper.GenerateHash(a.StaraLozinka, db.LozinkaSalt)) == db.LozinkaHash) { db.LozinkaSalt = WebHelper.GenerateSalt(); db.LozinkaHash = WebHelper.GenerateHash(a.PotvrdnaLozinka, db.LozinkaSalt); ctx.SaveChanges(); return(RedirectToAction("Logout", "Login")); } else { return(RedirectToAction("Index", new { ok = 1 })); } }
public IActionResult PromijeniPassword(ProfilVM VM) { Korisnik logirani = HttpContext.GetLogiraniKorisnik(); bool IsAdmin = logirani.Uloge.Naziv == "Administrator"; if (!IsAdmin && VM.Id != logirani.Id) { return(Forbid()); } Korisnik k = _db.Korisnici.Find(VM.Id); if (VM.oldPassword == k.password || (IsAdmin && VM.Id != logirani.Id)) { if (VM.newpassword != k.password) { k.password = VM.newpassword; TempData["SuccessPoruka"] = "Lozinka uspješno promijenjena!"; } else { TempData["ErrorPoruka"] = "Vaša nova lozinka se mora razlikovati od trenutne!"; } } _db.SaveChanges(); return(RedirectToAction("Profil", new { @Id = VM.Id })); }
public UrediProfilPage() { InitializeComponent(); BindingContext = model = new ProfilVM() { LogiraniClan = Global.LogiraniClan }; }
public ProfilPage(Clan clan) { InitializeComponent(); BindingContext = model = new ProfilVM() { LogiraniClan = clan }; }
public IActionResult Dodaj(int Id) // UlogaId { ProfilVM VM = new ProfilVM() { UlogaId = Id }; return(View(VM)); }
public ActionResult ProfilEdit(ProfilVM model, int id) { try { var updateMember = db.Members.FirstOrDefault(x => x.ID == id); updateMember.Name = model.Members.Name; updateMember.Surname = model.Members.Surname; if (string.IsNullOrEmpty(model.Members.Password) == false) { updateMember.Password = model.Members.Password; } //resim yükleme işlemi if (Request.Files != null && Request.Files.Count > 0) { var file = Request.Files[0]; if (file.ContentLength > 0) { //resmin fiziksel klasörü var folder = Server.MapPath("~/Uploads/uyeResimler"); //resmi jpg uzantılı guid ile var fileName = Guid.NewGuid() + ".jpg"; //resim kaydedildi file.SaveAs(Path.Combine(folder, fileName)); //veritabanına resmi gösterme işlemi var filePath = "Uploads/uyeResimler/" + fileName; updateMember.MemberPicturePath = filePath; } } db.SaveChanges(); return(RedirectToAction("Profil", "Members")); } catch (Exception ex) { ViewBag.MyError = ex.Message; var viewModel = new Models.Account.ProfilVM() { Members = db.Members.FirstOrDefault(x => x.ID == id) }; return(View(viewModel)); } }
public IActionResult UrediProfil(ProfilVM model) { MyContext db = new MyContext(); UrediProfilVM vm = new UrediProfilVM() { ClanID = model.ClanID, Email = db.Clan.Where(w => w.ClanID == model.ClanID).Select(s => s.Email).FirstOrDefault(), KorisnickoIme = model.KorisnickoIme, Lozinka = model.Lozinka }; return(View(vm)); }
// GET: Profil public ActionResult Index(int?ok) { Kupci x = ctx.Kupci.Where(y => y.KupacID == GlobalHelp.prijavljeniKupac.KupacID).FirstOrDefault(); var model = new ProfilVM { KupacID = x.KupacID, Ime = x.Ime, Prezime = x.Prezime, Email = x.Email, KorisnickoIme = x.KorisnickoIme }; ViewBag.Uspjesno = ok; return(View("Index", model)); }
public ActionResult ProfilEdit(int id) { var user = db.Members.FirstOrDefault(x => x.ID == id); if (user == null) { return(RedirectToAction("Index", "Home")); } ProfilVM model = new ProfilVM() { Members = user, }; return(View(model)); }
public IActionResult Profil(int Id) { Korisnik k; if (Id == 0) { k = HttpContext.GetLogiraniKorisnik(); } else { Korisnik logirani = HttpContext.GetLogiraniKorisnik(); bool IsAdmin = logirani.Uloge.Naziv == "Administrator"; if (logirani.Id == Id || IsAdmin) { k = _db.Korisnici.Find(Id); } else { return(RedirectToAction("Profil", new { @Id = logirani.Id })); } } ProfilVM VM = new ProfilVM { datumRodjenja = k.datumRodjenja, Email = k.Email, Ime = k.Ime, Prezime = k.Prezime, Spol = k.Spol, Telefon = k.Telefon, ZemljaPorijekla = k.ZemljaPorijekla, Id = k.Id, Adresa = k.Adresa, Grad = k.Grad }; return(View(VM)); }
public IActionResult Profil(int?id) { if (id == null) { Korisnik k = HttpContext.GetLogiraniKorisnik(); if (k.Clan != null) { id = k.Clan.ClanId; } } ViewData["_ctx"] = _ctx; List <ProfilVM> model = new List <ProfilVM>(); Clan c = _ctx.Clanovi.Include(x => x.Grad).Where(x => x.ClanId == id).FirstOrDefault(); ViewData["clan"] = c; if (c != null) { List <ObjaveClanova> objave = _ctx.ObjaveClanova.OrderByDescending(x => x.DatumObjave).Include(x => x.Clan).Include(x => x.Clan.Grad).Where(x => x.ClanId == id).ToList(); ViewData["followers"] = GetFollowers((int)id, "followers"); ViewData["following"] = GetFollowers((int)id, "following"); foreach (var item in objave) { ProfilVM temp = new ProfilVM(); temp.Objava = item; temp.BrojKomentara = GetBrKomentara(item.ObjaveClanovaId); temp.Komentari = GetKomentari(item.ObjaveClanovaId); temp.Lajkovi = GetLajkovi(item.ObjaveClanovaId); temp.KoJeLajkao = GetKoJeLajkao(temp.Lajkovi, item.ObjaveClanovaId); model.Add(temp); } return(View("Profil", model)); } return(RedirectToAction("Index")); }
//private readonly MyContext db; //public ProfilController(MyContext context) //{ // db = context; //} public IActionResult Prikaz() { MyContext db = new MyContext(); var lk = HttpContext.GetLogiraniKorisnik(); var clanID = db.Clan.Where(x => x.NalogID == lk.Id).FirstOrDefault().ClanID; ProfilVM vm = new ProfilVM() { ClanID = clanID, Naziv = db.Clan.Where(c => c.ClanID == clanID).Select(s => s.Ime + " " + s.Prezime).FirstOrDefault(), KorisnickoIme = db.Clan.Where(c => c.ClanID == clanID).Select(s => s.KorisnickiNalog.KorisnickoIme).FirstOrDefault(), Lozinka = db.Clan.Where(c => c.ClanID == clanID).Select(s => s.KorisnickiNalog.Lozinka).FirstOrDefault(), Teretane = db.ClanTeretana.Where(c => c.ClanID == clanID).Select(s => new ProfilVM.Row { TeretanaID = s.TeretanaID, Naziv = s.Teretana.Naziv, Komentar = db.KomentarTeretane.Where(c => c.ClanID == clanID && c.TeretanaID == s.TeretanaID).Select(k => k.Komentar).FirstOrDefault() }).ToList(), Treninzi = db.treninziDetalji.Where(c => c.ClanID == clanID).Select(s => new ProfilVM.Row2 { TreninziDetaljiID = s.TreninziDetaljiID, Teretana = db.Treninzi.Where(w => w.TreninziID == s.TreninziID).Select(s => s.Teretana.Naziv).FirstOrDefault(), Otkazan = s.Otkazan, DatumVrijeme = s.Treninzi.DatumOdrzavanja.ToString("dd.MM.yyyy") + " (" + s.Treninzi.PocetakTreninga + "-" + s.Treninzi.KrajTreninga + ")" }).ToList(), clanarine = db.PlacanjeClanarine.Where(w => w.ClanID == clanID).Select(s => new ProfilVM.Row3 { Teretana = s.Teretana.Naziv, Datum = s.DatumUplate.ToString("dd.MM.yyyy"), Popust = s.Popust, TipClanarine = s.TipClanarine.Tip, Ukupno = s.UkupanIznos }).ToList() }; return(View(vm)); }
public ActionResult ProfilSnimi(ProfilVM a) { if (!ModelState.IsValid) { return(View("Index", a)); } Kupci db; db = ctx.Kupci.Where(o => o.KupacID == a.KupacID).FirstOrDefault(); db.Ime = a.Ime; db.Prezime = a.Prezime; db.Email = a.Email; db.KorisnickoIme = a.KorisnickoIme; ctx.SaveChanges(); return(RedirectToAction("Logout", "Login")); }
public IActionResult SnimiProfil(ProfilVM VM) { Korisnik k; Korisnik logirani = HttpContext.GetLogiraniKorisnik(); bool IsAdmin = logirani.Uloge.Naziv == "Administrator"; if (VM.Id == 0) { if (IsAdmin) { Uloge u = _db.Uloge.Find(VM.UlogaId); if (u != null) { if (u.Naziv == "Upravnik" || u.Naziv == "Administrator") { Uposlenik up = new Uposlenik(); up.username = VM.username; up.password = VM.newpassword; up.UlogeId = VM.UlogaId; up.Ime = VM.Ime; up.Prezime = VM.Prezime; up.Telefon = VM.Telefon; up.datumRodjenja = VM.datumRodjenja; up.Adresa = VM.Adresa; up.ZemljaPorijekla = VM.ZemljaPorijekla; up.Grad = VM.Grad; up.Spol = VM.Spol; up.GodineIskustva = 0; up.isValid = true; up.Email = VM.Email; _db.Uposlenici.Add(up); _db.SaveChanges(); TempData["SuccessPorukaIzmjene"] = "Promjene uspješno spašene!"; return(RedirectToAction("Profil", new { @Id = up.Id })); } else { k = new Korisnik(); k.UlogeId = VM.UlogaId; _db.Korisnici.Add(k); } } else { return(RedirectToAction("Profil", new { @Id = logirani.Id })); } } else { return(RedirectToAction("Profil", new { @Id = logirani.Id })); } } else { if (logirani.Id == VM.Id || IsAdmin) { k = _db.Korisnici.Find(VM.Id); } else { return(RedirectToAction("Profil", new { @Id = logirani.Id })); } } k.Ime = VM.Ime; k.Prezime = VM.Prezime; k.Telefon = VM.Telefon; k.datumRodjenja = VM.datumRodjenja; k.Adresa = VM.Adresa; k.ZemljaPorijekla = VM.ZemljaPorijekla; k.Grad = VM.Grad; k.Spol = VM.Spol; _db.SaveChanges(); TempData["SuccessPorukaIzmjene"] = "Promjene uspješno spašene!"; return(RedirectToAction("Profil", new { @Id = k.Id })); }
public Profil() { InitializeComponent(); BindingContext = new ProfilVM(this); }
public ProfilView(IEventAggregator eventAggregator, IMyMessageDialog myMessageDialog) { InitializeComponent(); _viewModel = new ProfilVM(eventAggregator, myMessageDialog); DataContext = _viewModel; }