本文整理汇总了C#中Repository.First方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.First方法的具体用法?C# Repository.First怎么用?C# Repository.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.First方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSettings
public static Setting GetSettings()
{
using (SGContext db = new SGContext())
{
try
{
var settingRepo = new Repository<Setting>(db);
var settings = settingRepo.First();
return settings;
}catch(Exception){
return new Setting();
}
}
}
示例2: Commit_Store_Elements
public void Commit_Store_Elements()
{
ProductCategory cat = new ProductCategory {Name = "Temporary cat"};
_catRepo.Insert(cat);
_unitOfWork.Commit();
Assert.That(cat, Has.Property("Id").GreaterThan(0));
using (var ctx = new Context())
{
var adp = new DbContextAdapter(ctx);
var repo = new Repository<ProductCategory>(adp);
Assert.That(repo.First(pc => pc.Name == cat.Name), Is.Not.Null);
}
}
示例3: SinavOlustur
public static Result SinavOlustur(Sinav sinav, NameValueCollection collection)
{
using (SGContext db = new SGContext())
{
try
{
SinavOturum otur = new SinavOturum();
School sch = new School();
otur.Okullar = new List<School>();
sinav.SinavOturum = new List<SinavOturum>();
int oturumNo = 1;
//sinav.SinavDurum = db.SinavDurum.FirstOrDefault(d => d.KisaDurum == "Onaylanmadı");
foreach (var item in collection.AllKeys)
{
if (item.Contains("sinavoturum_Tarih"))
{
otur = new SinavOturum();
otur.Tarih = Convert.ToDateTime(collection.GetValues(item)[0]);
}
else if (item.Contains("sinavoturum_Saat"))
{
otur.Saat = collection.GetValues(item)[0];
otur.OturumNo = oturumNo++;
otur.SinavOturumDurumId = (int)SG_DAL.Enums.EnumSinavDurum.OnaylanmamisSinav;
sinav.SinavOturum.Add(otur);
}
else if (item.Contains("duallistbox_okullar"))
{
foreach (var okulid in collection.GetValues(item))
{
var okulRepo = new Repository<School>(db);
int id = Convert.ToInt32(okulid);
var okul = okulRepo.First(d => d.SchoolId == id);
//////////////////////
//////////////////////
List<SinavOturumOkullari> oturumokullist = new List<SinavOturumOkullari>();
foreach (var sinavoturumlari in sinav.SinavOturum)
{
sinavoturumlari.Okullar.Add(okul);
}
}
}
}
var sinavRepo = new Repository<Sinav>(db);
sinavRepo.Add(sinav);
var sinavOturumlari = SinavManager.GetSinavOturumlari(sinav.SinavId);
foreach (var oturum in sinavOturumlari)
{
var sinavoturumokulu = new SinavOturumOkullari();
var sinavOtrOkul = SchoolManager.GetSinavOturumOkullari(oturum.SinavOturumId);
foreach (var okul in sinavOtrOkul)
{
sinavoturumokulu.SchoolId = okul.SchoolId;
sinavoturumokulu.SinavOturumId = oturum.SinavOturumId;
sinavoturumokulu.AsilGozetmenSayisi = 0;
sinavoturumokulu.YedekGozetmenSayisi = 0;
db.SinavOturumOkullari.Add(sinavoturumokulu);
db.SaveChanges();
}
}
result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
return result;
}
catch (Exception)
{
result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
return result;
}
}
}
示例4: GetSinavOturumOkulu
public static SinavOturumOkullari GetSinavOturumOkulu(int okulID, int SinavOturumId)
{
using (SGContext db = new SGContext())
{
try
{
var repo = new Repository<SinavOturumOkullari>(db);
var okul = repo.First(d => d.SchoolId == okulID && d.SinavOturumId == SinavOturumId);
return okul;
}
catch (Exception)
{
return null;
}
}
}
示例5: GetSinavGorevli
public static SinavGorevli GetSinavGorevli(int SinavOturumId, int TeacherId)
{
using (SGContext db = new SGContext())
{
try
{
var gorevliRepo = new Repository<SinavGorevli>(db);
var gorevli = gorevliRepo.First(d => d.SinavOturumId == SinavOturumId && d.TeacherId == TeacherId);
return gorevli;
}
catch (Exception)
{
return null;
}
}
}
示例6: updateTeacher
public static Result updateTeacher(User newUser, Teacher teacher)
{
using (SGContext db = new SGContext())
{
try
{
var userRepository = new Repository<User>(db);
var tchRepo = new Repository<Teacher>(db);
var user = userRepository.First(d => d.UserId == newUser.UserId);
var tch = tchRepo.First(d => d.TeacherId == teacher.TeacherId);
user.Ad = newUser.Ad;
user.Email = newUser.Email;
user.Soyad = newUser.Soyad;
user.TCKimlik = newUser.TCKimlik;
user.Tel = newUser.Tel;
tch.GenelBasvuru = teacher.GenelBasvuru;
tch.Kidem = teacher.Kidem;
tch.SchoolId = teacher.SchoolId;
tch.Unvan = teacher.Unvan;
db.SaveChanges();
result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
return result;
}
catch (Exception)
{
result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
return result;
}
}
}
示例7: ReadTeachersFromExcel
public static List<Teacher> ReadTeachersFromExcel(string filePath)
{
var data = new StringBuilder();
try
{
Net.SourceForge.Koogra.IWorkbook wb = null;
string fileExt = Path.GetExtension(filePath);
if (string.IsNullOrEmpty(fileExt))
{
throw new Exception("File extension not found");
}
if (fileExt.Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
{
wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcel2007Reader(filePath);
}
else if (fileExt.Equals(".xls", StringComparison.OrdinalIgnoreCase))
{
wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcelBIFFReader(filePath);
}
Net.SourceForge.Koogra.IWorksheet ws = wb.Worksheets.GetWorksheetByIndex(0);
List<Teacher> list = new List<Teacher>();
for (uint r = ws.FirstRow + 1; r <= ws.LastRow; ++r)
{
Net.SourceForge.Koogra.IRow row = ws.Rows.GetRow(r);
if (row != null)
{
Teacher teacher = new Teacher();
teacher.User = new User();
teacher.Unvan = (int)SG_DAL.Enums.EnumUnvan.Ogretmen;
teacher.GenelBasvuru = true;
teacher.User.Rol = (int)SG_DAL.Enums.EnumRol.ogretmen;
teacher.GorevSayisi = 0;
for (uint colCount = ws.FirstCol; colCount <= ws.LastCol; ++colCount)
{
string cellData = string.Empty;
if (row.GetCell(colCount) != null && row.GetCell(colCount).Value != null)
{
cellData = row.GetCell(colCount).Value.ToString();
switch (colCount)
{
case 0: teacher.User.Ad = cellData;
break;
case 1: teacher.User.Soyad = cellData;
break;
case 2: teacher.User.TCKimlik = Convert.ToInt64(cellData);
teacher.User.Sifre = cellData;
break;
case 3: teacher.User.Email = cellData;
break;
case 4: teacher.User.Tel = cellData;
break;
case 5: teacher.Kidem = cellData;
break;
case 6:
using (SGContext db = new SGContext())
{
var schoolRepo = new Repository<School>(db);
int mebkodu = Convert.ToInt32(cellData);
School sch = schoolRepo.First(d => d.MebKodu == mebkodu);
teacher.SchoolId = sch.SchoolId;
}
break;
default:
break;
}
}
}
list.Add(teacher);
}
}
return list;
}
catch (Exception)
{
return new List<Teacher>();
}
}
示例8: Decklist
public void Decklist()
{
var decklists = new Repository().GetDecklist("20866");
Assert.IsNotNull(decklists);
Assert.AreEqual(20866, decklists.First().Id);
}
示例9: OneCard
public void OneCard()
{
var oneCards = new Repository().GetCard("01001");
Assert.IsNotNull(oneCards);
Assert.AreEqual(oneCards.First().Title, "Noise: Hacker Extraordinaire");
}
示例10: OkulGuncelle
public static Result OkulGuncelle(School guncelokul)
{
using (SGContext db = new SGContext())
{
try
{
var repo = new Repository<School>(db);
School okul = repo.First(d => d.SchoolId == guncelokul.SchoolId);
okul.MebKodu = guncelokul.MebKodu;
okul.Ad = guncelokul.Ad;
repo.UpdateSaveChanges();
result = new Result("İşlem başarılı", SystemRess.Messages.basarili_durum.ToString());
return result;
}
catch (Exception)
{
result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
return result;
}
}
}