public LoginModel Login(string username, string password) { LoginModel returndata = new LoginModel(); using (var context = new TPContext()) { var data = context.Memberships.Where(x => x.UserName == username && x.Password == password).ToList(); if (data.Count > 0) { if (data.First().IsActive == true) { returndata.LoginMessage = "User Found"; returndata.UserName = data.First().UserName; } else { returndata.LoginMessage = "User Inactive"; returndata.UserName = data.First().UserName; } } else { returndata.LoginMessage = "No User Found"; returndata.UserName = null; } return(returndata); } }
public ActionResult Login(EmployeeLoginVM userAuthInfo) { if (ModelState.IsValid) { //need to get the Employee ID from the login table //Use that ID to identify if that employee is a manager var context = new TPContext(); var EmployeeLogin = context.EmployeeLogins.Single(x => x.LoginEmail == userAuthInfo.Username && x.Pswd == userAuthInfo.Password); if (EmployeeLogin != null && context.MANAGED_BY.Any(x => x.EmployeeID == EmployeeLogin.EmployeeID)) { ApplicationSession.AccessLevel = "Manager"; ApplicationSession.Username = userAuthInfo.Username; return(Redirect("/Home/ManagerHub")); } else if (EmployeeLogin != null) { ApplicationSession.AccessLevel = "Employee"; ApplicationSession.Username = userAuthInfo.Username; return(Redirect("/Home/EmployeeHub")); } else { // Display error ModelState.AddModelError(string.Empty, "Invalid Username or Password"); return(View(userAuthInfo)); } } else { return(View()); } }
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) { if (FormsAuthentication.CookiesSupported == true) { if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { try { //let us take out the username now string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; string roles = string.Empty; using (TPContext entities = new TPContext()) { roles = entities.Zaposlenici.Include("Uloga").Where(x => x.Email == username).FirstOrDefault().Uloga.Naziv; } //let us extract the roles from our own custom cookie //Let us set the Pricipal with our user specific details HttpContext.Current.User = new System.Security.Principal.GenericPrincipal( new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';')); } catch (Exception) { //somehting went wrong } } } }
public string GetUserRole(string username) { using (var context = new TPContext()) { var temp = (from e in context.Memberships where e.UserName == username select e.RoleId).First(); var temp2 = (from e in context.Roles where e.Id == temp.Id select e.Name).First(); return(temp2); } }
public List <Role> GetRoles() { using (var context = new TPContext()) { List <Role> roles = (from e in context.Roles where e.IsActive == true select new Role { Id = e.Id, Name = e.Name, IsActive = e.IsActive, CreatedDate = e.CreatedDate }).ToList(); return(roles); } }
public static List <Odsustva> GetBodyOdsustva(int vozacId) { TPContext ctx = new TPContext(); return(ctx.Odsustva.Where(x => x.ZaposlenikId == vozacId).Select( y => new Odsustva { datumDo = y.DatumDo, datumOd = y.DatumOd, tipOdsustva = y.TipOdsustva.Naziv } ).ToList()); }
public string RegisterUser(Membership membership) { string returndata = ""; using (var context = new TPContext()) { Membership membership1 = new Membership(); context.Memberships.Add(membership1); returndata = "Data Created"; } return(returndata); }
public static List <Stavka> GetBody(int dispozicijaId) { TPContext ctx = new TPContext(); return(ctx.Stavke.Where(x => x.DispozicijaId == dispozicijaId).Select( y => new Stavka { Naziv = y.Naziv, Kolicina = y.Kolicina, JedinicaMjere = y.KolicinaTip.Naziv } ).ToList()); }
public ActionResult Login(LoginVM model, string returnUrl) { if (ModelState.IsValid) { using (TPContext objContext = new TPContext()) { objUser = objContext.Zaposlenici.FirstOrDefault(x => x.Email == model.Username && x.Password == model.Password); if (objUser == null) { ModelState.AddModelError("LogOnError", "Korisničko ime ili šifra su neispravni."); } else { FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { string[] roles = new string[1]; roles = Roles.GetRolesForUser(objUser.Email); if (roles[0] == "dispečer") { return(RedirectToAction("Index", "Dispozicija", new { area = "ModulDispecer" })); } if (roles[0] == "logističar") { return(RedirectToAction("Index", "Vozilo", new { area = "ModulLogistika" })); } if (roles[0] == "vozač") { Global.odabraniVozac = objUser; return(RedirectToAction("Prikazi", "Instradacije", new { area = "ModulVozac" })); } if (roles[0] == "mehaničar") { Global.odabraniVozac = objUser; return(RedirectToAction("Prikazi", "Dobavljac", new { area = "ModulMehanicar" })); } } } } } return(View(model)); }
public static List <Kartice> GetBody(int vozacId) { TPContext ctx = new TPContext(); return(ctx.KarticaVozaci.Where(x => x.VozacId == vozacId).Select( y => new Kartice { datumKoristenja = y.DatumKoristenja, kolicina = y.KolicinaLitara, ukupanIznos = y.UkupanIznos, benzinskaNaziv = y.BenzinskaPumpa.Adresa } ).ToList()); }
public static List <Odrzavanja> GetBody(int voziloId) { TPContext ctx = new TPContext(); return(ctx.Odrzavanja.Where(x => x.VoziloId == voziloId).Select( y => new Odrzavanja { datum = y.Datum, kilometraza = y.Kilometraza, tipOdrzavanja = y.TipOdrzavanja.Naziv, troskovi = y.Troskovi } ).ToList()); }
public static List <Instradacija> GetBodyInstradacije(int voziloId) { TPContext ctx = new TPContext(); return(ctx.Instradacije.Where(x => x.VoziloId == voziloId).Select( y => new Instradacija { datum = y.Datum, izlaznaCarina = y.IzlaznaCarinarnica ?? 1, ulaznaCarina = y.UlaznaCarinarnica ?? 1, statusInstradacije = y.StatusInstradacije.Naziv } ).ToList()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, TPContext db) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } DbInitializer.InitializeData(db); app.UseHttpsRedirection(); app.UseMvc(); }
public static List <Primalac> GetPrimalacInfo(int dispozicijaId) { TPContext ctx = new TPContext(); Primalac primalac = new Primalac(); List <Primalac> p = new List <Primalac>(); primalac = ctx.Dispozicije.Where(x => x.DispozicijaId == dispozicijaId).Select(y => new Primalac { Naziv = y.Primalac, Adresa = y.AdresaDo, Država = y.DrzavaDo.Naziv }).FirstOrDefault(); p.Add(primalac); return(p); }
public static List <Header> GetHeader(int dispozicijaId) { TPContext ctx = new TPContext(); List <Header> header = new List <Header>(); Header h = new Header(); h.AdresaPreduzeca = "Mostarsko raskršće bb, Sarajevo"; h.PDV = "123123456"; h.JIB = "547574585696"; h.NazivPreduzeca = "Cargo Trans"; h.ZiroRacun = "1234 5678 9123 3456"; header.Add(h); return(header); }
public static List <DispozicijaInfo> GetDispozicijaInfo(int dispozicijaId) { TPContext ctx = new TPContext(); DispozicijaInfo d = ctx.Dispozicije.Where(x => x.DispozicijaId == dispozicijaId).Select(y => new DispozicijaInfo { Datum = y.DatumDispozicije, DatumIspostave = y.DatumIspostave, DatumPlacanja = y.DatumPlacanja, Cijena = y.Cijena, RacunBroj = y.RowGuid, DodatneInformacije = y.DodatneInformacije }).FirstOrDefault(); List <DispozicijaInfo> info = new List <DispozicijaInfo>(); info.Add(d); return(info); }
public static List <InstradacijaInfo> GetInstradacijaInfos(int instradacijaId) { TPContext ctx = new TPContext(); InstradacijaInfo i = ctx.Instradacije.Where(x => x.InstradacijaId == instradacijaId).Select(y => new InstradacijaInfo { Datum = y.Datum, ulaznaCarinarnica = (int)y.UlaznaCarinarnica, izlaznaCarinarnica = (int)y.IzlaznaCarinarnica, prikljucnoVozilo = y.PrikljucnoVozilo.RegistarskeOznake, vozilo = y.Vozilo.RegistarskeOznake, status = y.StatusInstradacije.Naziv }).FirstOrDefault(); List <InstradacijaInfo> info = new List <InstradacijaInfo>(); info.Add(i); return(info); }
public override string[] GetRolesForUser(string username) { using (TPContext objContext = new TPContext()) { var objUser = objContext.Zaposlenici.Include("Uloga").Where(x => x.Email == username).FirstOrDefault().Uloga.Naziv; string uloga = objUser.ToString(); if (objUser == null) { return(null); } else { string[] ret = new string[1]; ret[0] = objUser.ToString(); return(ret); } } }
public static List <VozacInformacije> getVozaciInformacije(int vozacId) { TPContext ctx = new TPContext(); List <VozacInformacije> p = new List <VozacInformacije>(); VozacInformacije vozac = new VozacInformacije(); vozac = ctx.Vozaci.Where(x => x.ZaposlenikId == vozacId).Select(y => new VozacInformacije { Ime = y.Ime, Prezime = y.Prezime, Adresa = y.Adresa, JMBG = y.JMBG, Telefon = y.Telefon }).FirstOrDefault(); p.Add(vozac); return(p); }
public static List <Posiljalac> GetPosiljalacInfo(int dispozicijaId) { TPContext ctx = new TPContext(); List <Posiljalac> p = new List <Posiljalac>(); Posiljalac posiljalac = new Posiljalac(); posiljalac = ctx.Dispozicije.Where(x => x.DispozicijaId == dispozicijaId).Select(y => new Posiljalac { Naziv = y.Klijent.Naziv, Adresa = y.Klijent.Adresa, Drzava = y.Klijent.Drzava.Naziv, Kontakt = y.Klijent.Telefon }).FirstOrDefault(); p.Add(posiljalac); return(p); }
public static List <VoziloInformacije> getVozilaInformacije(int voziloId) { TPContext ctx = new TPContext(); List <VoziloInformacije> p = new List <VoziloInformacije>(); VoziloInformacije vozilo = new VoziloInformacije(); vozilo = ctx.Vozila.Where(x => x.VoziloId == voziloId).Select(y => new VoziloInformacije { brojSasije = y.BrojSasije, regOznake = y.RegistarskeOznake, Proizvodjac = y.Proizvodzac, nosivost = y.Nosivost, DatumRegistracije = y.DatumRegistracije, godinaProizvodnje = y.GodinaProizvodnje, statusVozila = y.StatusVozila.Naziv, tipVozila = y.TipVozila.Naziv }).FirstOrDefault(); p.Add(vozilo); return(p); }
public ActionResult Login(SPHLoginVM userAuthInfo) { if (ModelState.IsValid) { var context = new TPContext(); var SPHLogin = context.SPHLogins.First(); if (context.SPHLogins.Any(x => x.LoginEmail == userAuthInfo.Username && x.Pswd == userAuthInfo.Password)) { ApplicationSession.AccessLevel = "SPH"; ApplicationSession.Username = userAuthInfo.Username; return(Redirect("/Home/SPH_Profile")); } else { // Display error ModelState.AddModelError(string.Empty, "Invalid Username or Password"); return(View(userAuthInfo)); } } else { return(View()); } }
public VisitsController(TPContext context, IVisitsRepo iRepo) { _context = context; _iRepo = iRepo; }
public UsuariosController(TPContext context) { _context = context; }
public ProdutosController(TPContext context) { _context = context; }
public SignInsController(TPContext context, ISignInRepo iRepo) { _context = context; _iRepo = iRepo; }
public BaseRepo() { _db = new TPContext(); }
public BaseRepo(DbContextOptions options) { _db = new TPContext(options); }