예제 #1
0
 private domain.Oblast ToDomain(model.Oblast modelObject)
 {
     domain.Oblast domainObject = new domain.Oblast();
     domainObject.Id  = modelObject.ID;
     domainObject.Ime = modelObject.Ime;
     return(domainObject);
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
        }