Пример #1
0
        public static void Add(Model.ProjectModal project)
        {
            using (DataAccess.TeamDBEntities context = new DataAccess.TeamDBEntities())
            {
                Mapper.CreateMap<Model.ProjectModal, Project>();
                Project projectAdd = Mapper.Map<Project>(project);

                context.Projects.Add(projectAdd);

                context.SaveChanges();
            }
        }
Пример #2
0
        public static void Update(Model.ProjectModal project)
        {
            using (DataAccess.TeamDBEntities context = new DataAccess.TeamDBEntities())
            {
                Project item = (from p in context.Projects
                                where p.ID == project.ID
                                select p).FirstOrDefault();

                Mapper.CreateMap<Model.ProjectModal, Project>();
                Mapper.Map(project, item);

                context.SaveChanges();
            }
        }
Пример #3
0
        public static void Delete(int id)
        {
            using (DataAccess.TeamDBEntities context = new DataAccess.TeamDBEntities())
            {
                var project = (from p in context.Projects
                               where p.ID == id
                               select p).FirstOrDefault();
                context.Projects.Attach(project);
                context.Projects.Remove(project);

                context.SaveChanges();
            }
        }