private domain.Oblast ToDomain(model.Oblast modelObject) { domain.Oblast domainObject = new domain.Oblast(); domainObject.Id = modelObject.ID; domainObject.Ime = modelObject.Ime; return(domainObject); }
public domain.Oblast Delete(domain.Oblast domainObject) { using (var context = CreateContext()) { var modelObject = context.Oblasts.Single(org => org.ID == domainObject.Id); context.Oblasts.DeleteOnSubmit(modelObject); context.SubmitChanges(); var deletedObject = ToDomain(modelObject); return(deletedObject); } }
public domain.Oblast Get(int id) { using (model.LearnByPracticeDataContext context = CreateContext()) { IQueryable <model.Oblast> query = context.Oblasts.Where(c => c.ID == id); domain.Oblast domainObject = ToDomain(query.Single()); return(domainObject); } }
public domain.Oblast Update(domain.Oblast domainObject) { using (model.LearnByPracticeDataContext context = CreateContext()) { IQueryable <model.Oblast> query = context.Oblasts.Where(p => p.ID == domainObject.Id); model.Oblast modelObject = query.Single(); modelObject.Ime = domainObject.Ime; context.SubmitChanges(); domain.Oblast result = ToDomain(modelObject); return(result); } }
public domain.Oblast Insert(domain.Oblast domainObject) { using (model.LearnByPracticeDataContext context = CreateContext()) { model.Oblast modelObject = new model.Oblast(); modelObject.Ime = domainObject.Ime; context.Oblasts.InsertOnSubmit(modelObject); context.SubmitChanges(); domain.Oblast result = ToDomain(modelObject); return(result); } }
public domain.OblastCollection GetAll() { model.LearnByPracticeDataContext context = CreateContext(); IQueryable <model.Oblast> query = context.Oblasts; domain.OblastCollection result = new domain.OblastCollection(); foreach (model.Oblast modelObject in query) { domain.Oblast domainObject = new domain.Oblast(); domainObject.Id = modelObject.ID; domainObject.Ime = modelObject.Ime; result.Add(domainObject); } return(result); }