public UsersController(Models.Context context, UserManager <Models.User> userManager, SignInManager <Models.User> signInManager) { ViewBag.IsLogged = false; this.context = context; this.userManager = userManager; this.signInManager = signInManager; }
//________________________________________________________________________ public async Task <ActionResult> Index() { //const long SAMPLE_FILE_ID = 123; //using (var w = await FileStorage.Current.CreateTextAsync(SAMPLE_FILE_ID)) //{ // w.WriteLine("Line1"); // w.WriteLine("Line2"); // w.WriteLine("Line3"); //} //using (var w = await FileStorage.Current.AppendTextAsync(SAMPLE_FILE_ID)) //{ // w.WriteLine("Line4"); // w.WriteLine("Line5"); //} //using (var w = await FileStorage.Current.CreateTextAsync(SAMPLE_FILE_ID, "myMetaData")) //{ // w.WriteLine("Metadata attached to the main file"); //} IList <Models.File> list; using (var da = new Models.Context()) list = await da.Files.ToListAsync(); return(this.View(list)); }
public void TypeCipher() { for (int i = 0; i < LastRusSmallWord; i++) { ciph[i] = new Models.Cipher(); } Models.Context contx = new Models.Context(); for (int i = 1; i < LastRusSmallWord + 1; i++) { ciph[i - 1].Id = i; ciph[i - 1].oldSymbolId = ((FirstRusBigWord + i - 1)); int place = FirstRusBigWord + i + 6; if (place > LastRusSmallWord) { place = place - 64; } ciph[i - 1].newSymbol = ((char)place).ToString(); contx.CipherTable.Add(ciph[i - 1]); } contx.SaveChanges(); Models.Context test = new Models.Context(); Models.Cipher temp = new Models.Cipher(); foreach (Models.Cipher a in test.CipherTable) { temp = a; } }
public ActionResult EdytujKarta(int id) { var context = new Models.Context(); var program = context.ProgramyStudiow.Where(p => !p.Usuniety.HasValue).FirstOrDefault(p => p.Id == id); var karta = new NowaKarta() { Id = program.Id, WydzialId = program.WydzialId, KierunekId = program.KierunekId, PoziomId = program.PoziomId, ProfilKsztalceniaId = program.ProfilKsztalceniaId, ObszarKsztalceniaId = program.ObszarKsztalceniaId, GrupaPrzedmiotowId = program.GrupaPrzedmiotowId, SemestrId = program.SemestrId, FormaZaliczeniaId = program.FormaZaliczeniaId, WykladowcaId = program.WykladowcaId, NazwaPrzedmiotu = program.Nazwa, SpecjalnoscId = program.SpecjalnoscId, Kod = program.Kod, DoWyboru = program.PrzedmiotDoWyboru, ECTS = program.ECTS }; UzupelnijProgramStudiow(context, karta); karta.Godziny.ForEach(g => { var znanaGodzina = program.LiczbyGodzin.FirstOrDefault(lg => lg.TypLiczbaGodzinId == g.TypLiczbGodzinId); if (znanaGodzina != null) { g.Stacjonarne = znanaGodzina.Stacjonarne; g.Niestacjonarne = znanaGodzina.Niestacjonarne; } }); return(View("NowaKarta", karta)); }
public static decimal SelecionaClassificacao(string GameId) { Gamer.Models.Context db = new Models.Context(); int gameid = Convert.ToInt32(GameId); var rates = db.Rates.Where(c => c.GameId == gameid).Select(gp => new { Rates = gp.Rating }); int resultcount = rates.Count(); int resultif = 1; try { var resultRates = rates.Sum(c => c.Rates); } catch (Exception ex) { resultif = 2; } if (resultif == 1) { int resultTotal = rates.Sum(c => c.Rates); decimal medium = Convert.ToDecimal(resultTotal) / Convert.ToDecimal(resultcount); return(medium); } else { decimal medium = Convert.ToDecimal(0.00); return(medium); } }
public string createFieldsScript(Models.Context db) { System.Text.StringBuilder script = new StringBuilder(); for (int i = 0; i < this.Fields.Count; i++) { KeyValuePair <String, Type> field = this.Fields[i]; if (dataMapper.ContainsKey(field.Value)) { string query = "\t " + $"ALTER TABLE report.Device ADD {_prefix}{field.Key} {dataMapper[field.Value]};"; try { Helper.executeNonQUery(query, db); script.Append(query); } catch { } } else { // Complex Type? TableClass addTypes = new TableClass(field.Value, _prefix + field.Key + "_"); script.Append(addTypes.createFieldsScript(db)); } script.Append(Environment.NewLine); } return(script.ToString()); }
public static Dictionary <object, object> SelecionaLinhasBanco() { Dictionary <object, object> dic = new Dictionary <object, object>(); Gamer.Models.Context db = new Models.Context(); var result2 = (from p in db.Transacoes group p by p.Tday into g select new { TransactionCode = g.Key, Quantidade = g.Count() }).OrderBy(o => o.TransactionCode);; var result = db.Transacoes.OrderBy(c => c.Tday).Select(gp => new { TQuantity = gp.TCount, TDia = gp.Tday }); int Quantity = result.Sum(c => c.TQuantity); foreach (var item in result2) { dic.Add(item.TransactionCode, item.Quantidade); } return(dic); }
public ActionResult Index() { ViewBag.Dziekan = User.IsInRole("Dziekan"); ViewBag.Biuro = User.IsInRole("Biuro"); var context = new Models.Context(); var userID = User.Identity.GetUserId(); var user = context.Users.Include("Wydzialy.Wydzial.Program").FirstOrDefault(u => u.Id == userID); if (user == null) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("Index", "Home")); } List <Program> przedmiotWProgramach; if (ViewBag.Dziekan || ViewBag.Biuro) { przedmiotWProgramach = user.Wydzialy.SelectMany(w => w.Wydzial.Program).Where(p => !p.Usuniety.HasValue).ToList(); } else { przedmiotWProgramach = context.ProgramyStudiow.Where(p => p.WykladowcaId == userID).Where(p => !p.Usuniety.HasValue).ToList(); } return(View(przedmiotWProgramach)); }
private void UserEditViewModelStale(Models.Context context, UserEditViewModel model) { var wydzialy = context.Wydzialy.ToList(); var tytuly = context.Tytuly.OrderBy(t => t.Kolejnosc).ToList(); var role = context.Roles.ToList(); model.Wydzialy = wydzialy.Select(w => new SelectListItem() { Value = w.Id.ToString(), Text = w.Nazwa, Selected = model.WybraneWydzialy.Any(ww => ww == w.Id) }).ToList(); model.Tytuly = tytuly.Select(w => new SelectListItem() { Value = w.Id.ToString(), Text = w.Nazwa, Selected = model.WybraneTytuly.Any(ww => ww == w.Id) }).ToList(); model.Role = role.Select(w => new SelectListItem() { Value = w.Id, Text = w.Name, Selected = model.WybraneRole.Any(ww => ww == w.Id) }).ToList(); }
public override string[] GetRolesForUser(string username) { Models.Context db = new Models.Context(); string rol = db.Kullanici.Include("Rol").Single(x => x.Email == username).Rol.Ad; return(new string[] { rol }); }
public IActionResult Index(String Paikka = aloitusPaikka, int Rahaa = aloitusRaha, String Suunta = alasString) { Models.Context context = new Models.Context(Paikka, Rahaa); switch (Suunta) { case ylosString: context.MeneYlos(); break; case oikealleString: context.MeneOikealle(); break; case vasemmalleString: context.MeneVasemmealle(); break; default: context.MeneAlas(); break; } ViewData["Rahaa"] = context.Rahaa; ViewData["Paikka"] = context.GetCurrentState(); ViewData["YlosString"] = context.GetYlosUri(); ViewData["AlasString"] = context.GetAlasUri(); ViewData["OikealleString"] = context.GetOikealleUri(); ViewData["VasemmalleString"] = context.GetVasemmalleUri(); return(View()); }
public ActionResult NowaKarta() { var karta = new NowaKarta(); var context = new Models.Context(); UzupelnijProgramStudiow(context, karta); return(View(karta)); }
public ActionResult NowyProgram(NowaKarta nowyProgram) { var context = new Models.Context(); var program = new Program(); if (nowyProgram.Id > 0) { program = context.ProgramyStudiow.Where(p => !p.Usuniety.HasValue).FirstOrDefault(p => p.Id == nowyProgram.Id); } program.WydzialId = nowyProgram.WydzialId; program.KierunekId = nowyProgram.KierunekId; program.PoziomId = nowyProgram.PoziomId; program.ProfilKsztalceniaId = nowyProgram.ProfilKsztalceniaId; program.ObszarKsztalceniaId = nowyProgram.ObszarKsztalceniaId; program.GrupaPrzedmiotowId = nowyProgram.GrupaPrzedmiotowId; program.SemestrId = nowyProgram.SemestrId; program.FormaZaliczeniaId = nowyProgram.FormaZaliczeniaId; program.WykladowcaId = nowyProgram.WykladowcaId; program.Nazwa = nowyProgram.NazwaPrzedmiotu; program.SpecjalnoscId = nowyProgram.SpecjalnoscId; program.Kod = nowyProgram.Kod; program.PrzedmiotDoWyboru = nowyProgram.DoWyboru; program.ECTS = nowyProgram.ECTS; program.LiczbyGodzin.ForEach(lg => { var godzina = nowyProgram.Godziny.FirstOrDefault(g => g.TypLiczbGodzinId == lg.TypLiczbaGodzinId); if (godzina != null) { lg.Stacjonarne = godzina.Stacjonarne < 0 ? 0 : godzina.Stacjonarne; lg.Niestacjonarne = godzina.Niestacjonarne < 0 ? 0 : godzina.Niestacjonarne; } }); nowyProgram.Godziny.Where(godzina => !program.LiczbyGodzin.Any(lg => lg.TypLiczbaGodzinId == godzina.TypLiczbGodzinId)).ForEach(godzina => { program.LiczbyGodzin.Add(new LiczbaGodzin() { TypLiczbaGodzinId = godzina.TypLiczbGodzinId, Stacjonarne = godzina.Stacjonarne < 0 ? 0 : godzina.Stacjonarne, Niestacjonarne = godzina.Niestacjonarne < 0 ? 0 : godzina.Niestacjonarne }); }); if (nowyProgram.Id > 0) { context.Entry(program).State = System.Data.Entity.EntityState.Modified; } else { context.ProgramyStudiow.Add(program); } context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult UserEdit(UserEditViewModel model) { var context = new Models.Context(); if (!ModelState.IsValid) { UserEditViewModelStale(context, model); return(View(model)); } var user = context.Users.First(u => u.Id == model.Id); user.Imie = model.Imie; user.Nazwisko = model.Nazwisko; var wydzialyDoUsuniecia = user.Wydzialy.Where(w => !model.WybraneWydzialy.Any(ww => ww == w.Id)).ToList(); wydzialyDoUsuniecia.ForEach(w => user.Wydzialy.Remove(w)); var tytulyDoUsuniecia = user.Tytuly.Where(w => !model.WybraneTytuly.Any(ww => ww == w.Id)).ToList(); tytulyDoUsuniecia.ForEach(w => user.Tytuly.Remove(w)); var roleDoUsuniecia = user.Roles.Where(w => !model.WybraneRole.Any(ww => ww == w.RoleId)).ToList(); roleDoUsuniecia.ForEach(w => user.Roles.Remove(w)); var wydzialyDoDodania = model.WybraneWydzialy.Where(ww => !user.Wydzialy.Any(w => w.Id == ww)).ToList(); wydzialyDoDodania.ForEach(ww => { user.Wydzialy.Add(new UzytkownikWydzialy() { WydzialId = ww }); }); var tytulyDoDodania = model.WybraneTytuly.Where(ww => !user.Tytuly.Any(w => w.Id == ww)).ToList(); tytulyDoDodania.ForEach(ww => { var t = context.Tytuly.Find(ww); user.Tytuly.Add(t); }); var roleDoDodania = model.WybraneRole.Where(ww => !user.Roles.Any(w => w.RoleId == ww)).ToList(); roleDoDodania.ForEach(ww => { user.Roles.Add(new Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole() { RoleId = ww }); }); context.Entry(user).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Uzytkownicy")); }
public ActionResult Delete(int id) { var context = new Models.Context(); var program = context.ProgramyStudiow.Where(p => !p.Usuniety.HasValue).FirstOrDefault(ps => ps.Id == id); program.Usuniety = DateTime.Now; context.Entry(program).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); }
private void btn_add_Click(object sender, EventArgs e) { ScrumTable.Models.Context db = new Models.Context(); Models.Drafts item = new Models.Drafts() { StoryId = this.StoryId, Content = txt_content.Text, Status = Convert.ToInt32((cbx_status.SelectedItem as Item).Value) }; db.Drafts.Add(item); db.SaveChanges(); MetroMessageBox.Show(this, "Kayıt başarıyla oluşturuldu!.."); this.Close(); }
public ActionResult MetodyOceniania() { var context = new Models.Context(); var metodyOceniania = context.MetodyOceniania.ToList(); var lista = metodyOceniania.Select(mo => new MetodyOcenianiaListElement() { Id = mo.Id, Nazwa = mo.Nazwa, LiczbaProgramow = mo.Programy.Count(), }); return(View(lista)); }
public bool Update(Models.Context context) { var oldContext = GetById(context.Id); if (oldContext == null) { return(false); } oldContext.Name = context.Name; return(Context.SaveChanges() > 0); }
public ValueTask <FileOption <long> > GetFileOptionAsync(long ID, string alternateDataStream) { var ret = FileOption <long> .Create(ID, alternateDataStream); if (!string.IsNullOrEmpty(alternateDataStream)) { return(new ValueTask <FileOption <long> >(ret)); } using (var da = new Models.Context()) { var row = da.Files.Find(ID); if (row == null) { return(default);
public ActionResult MetodyDydaktyczneCreate() { var context = new Models.Context(); var grupyMetod = new GrupyMetodList(); var grupyMetodDydaktycznych = new GrupyMetodDydaktycznych(); grupyMetod.GrupyMetod = context.GrupyMetodDydaktycznych.Select(w => new SelectListItem() { Text = w.Nazwa, Value = w.Id.ToString() }).ToList(); return(View(grupyMetod)); }
public ActionResult MetodyDydaktyczneCreate(MetodyDydaktyczne model) { var context = new Models.Context(); if (!ModelState.IsValid) { return(View(model)); } context.Metody.Add(model); context.SaveChanges(); return(RedirectToAction("MetodyDydaktyczne")); }
public ActionResult SpecjalnoscCreate(Specjalnosc model) { var context = new Models.Context(); if (!ModelState.IsValid) { return(View(model)); } context.Specjalnosci.Add(model); context.SaveChanges(); return(RedirectToAction("Specjalnosci", new { id = model.KierunekId })); }
public ActionResult KierunekCreate(Kierunek model) { var context = new Models.Context(); if (!ModelState.IsValid) { return(View(model)); } context.Kierunki.Add(model); context.SaveChanges(); return(RedirectToAction("Kierunki", new { id = model.WydzialId })); }
public ActionResult MetodyOcenianiaCreate(MetodyOceniania model) { var context = new Models.Context(); if (!ModelState.IsValid) { return(View(model)); } context.MetodyOceniania.Add(model); context.SaveChanges(); return(RedirectToAction("OperatingMode")); }
public string CreateTableScript() { Models.Context db = new Models.Context(); try { Helper.executeNonQUery("create table report.Device(runID int)", db); } catch { } System.Text.StringBuilder script = new StringBuilder(); script.AppendLine(createFieldsScript(db)); return(script.ToString()); }
public ActionResult WydzialCreate(Wydzial model) { var context = new Models.Context(); if (!ModelState.IsValid) { return(View(model)); } context.Wydzialy.Add(model); context.SaveChanges(); return(RedirectToAction("Wydzialy")); }
//GET: Metody/Delete/5 public ActionResult MetodyOcenianiaDelete(int id) { var context = new Models.Context(); var model = context.MetodyOceniania.Find(id); if (model.Programy.Any()) { throw new Exception("Nie można usunąć tej metody!"); } context.MetodyOceniania.Remove(model); context.SaveChanges(); return(RedirectToAction("MetodyOceniania")); }
public ActionResult WydzialDelete(int id) { var context = new Models.Context(); var model = context.Wydzialy.Find(id); if (model.Kierunki.Any() || model.Program.Any() || model.Uzytkownicy.Any()) { throw new Exception("Nie można usunąć tego wydziału!"); } context.Wydzialy.Remove(model); context.SaveChanges(); return(RedirectToAction("Wydzialy")); }
public ActionResult MetodyDydaktyczne() { var context = new Models.Context(); var metodyDydaktyczne = context.Metody.ToList(); var lista = metodyDydaktyczne.OrderBy(md => md.GrupyMetodDydaktycznychId).Select(md => new MetodyDydaktyczneListElement() { Id = md.Id, IdGrupy = md.GrupyMetodDydaktycznychId, Grupa = md.GrupyMetodDydaktycznych.Nazwa, Nazwa = md.Nazwa, LiczbaProgramow = md.Programy.Count(), }); return(View(lista)); }
public ActionResult SpecjalnoscDelete(int id) { var context = new Models.Context(); var model = context.Specjalnosci.Find(id); if (model.Programy.Any()) { throw new Exception("Nie można usunąć tego kierunku!"); } var kierunekId = model.KierunekId; context.Specjalnosci.Remove(model); context.SaveChanges(); return(RedirectToAction("Specjalnosci", new { id = kierunekId })); }