Exemplo n.º 1
0
        private void btnCreateData_Click(object sender, EventArgs e)
        {
            int parentId = 0;

            Int32.TryParse(tboxLocationsParentId.Text, out parentId);

            var parentLocation = Context.Locations.Where(x => x.ID == parentId).FirstOrDefault();

            var children = parentLocation.Children.ToList();

            parentLocation.Children.Clear();

            foreach (var location in children)
            {
                Context.Locations.DeleteObject(location);
            }

            var creatorId = (int)(comboUsers.SelectedValue);

            foreach (var location in _locations)
            {
                location.CreatedBy = creatorId;
                parentLocation.Children.Add(location);
            }

            Context.SaveChanges();
        }
Exemplo n.º 2
0
 public void SaveChanges()
 {
     context.SaveChanges();
 }
Exemplo n.º 3
0
 // CREATE
 public void AddRole(Role Role)
 {
     context.Roles.AddObject(Role);
     context.SaveChanges();
 }
Exemplo n.º 4
0
 public void AddUser(User user)
 {
     context.Users.AddObject(user);
     context.SaveChanges();
 }
Exemplo n.º 5
0
 public bool CreateItem(Resource item)
 {
     context.Resources.AddObject(item);
     context.SaveChanges();
     return(true);
 }