Exemplo n.º 1
0
        public CompanyDepartmentListitemViewmodel(Department that)
        {
            this.Id = that.Id;
            this.Name = that.Name;
            this.Bosses = that.Bosses.Select(q => new UserListitemViewmodel() { Id = q.Id, Name = q.UserName }).ToList();

            this.Groups = that.Groups.Select(q => new CompanyDepartmentGroupListitemViewmodel(q)).ToList();
        }
        public Department CreateDepartment(Department department)
        {
            db.Departments.Add(department);
            db.SaveChanges();

            return department;
        }
        public Department RemoveDepartment(Department department)
        {
            db.Departments.Remove(department);
            db.SaveChanges();

            return department;
        }
        public Department EditDepartment(Department department)
        {
            db.Entry(department).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return department;
        }