Beispiel #1
0
        public HtmlString AddNewSkill(string skillName, int index, int workerId)
        {
            var newIndex = NgProjectService.Add <Skill, int>(new Skill()
            {
                Name = skillName
            });

            return(new HtmlString(string.Format(@"<span class=""participant-skill-item"">{0}</span>", skillName, index, newIndex)));
        }
Beispiel #2
0
        public IActionResult Edit(int?id)
        {
            User user = null;

            if (id != null)
            {
                user = NgProjectService.FindUserById(id.Value);
            }
            return(View(user));
        }
Beispiel #3
0
        public HtmlString SetRoles(int roleId, int userId)
        {
            var lastRole = NgProjectService.FindByFunc <RolesUser, int>(t => t.RolesId == roleId && t.UsersId == userId);

            if (lastRole != null)
            {
                return(new HtmlString(""));
            }
            NgProjectService.Add <RolesUser, int>(new RolesUser()
            {
                RolesId = roleId,
                UsersId = userId
            });
            var sb   = new StringBuilder();
            var role = RolesService.Find(t => t.Id == roleId);

            sb.Append($"<span class=\"participant-skill-item\">{role.Name}</span>");
            return(new HtmlString(sb.ToString()));
        }
Beispiel #4
0
        public IActionResult SaveUser(User user)
        {
            if (user.ImageDataLocal != null)
            {
                byte[] imageData = null;
                using (var binaryReader = new BinaryReader(user.ImageDataLocal.OpenReadStream()))
                {
                    imageData = binaryReader.ReadBytes((int)user.ImageDataLocal.Length);
                }
                if (user.Image == null)
                {
                    user.Image = new Image();
                }

                user.Image.Data = imageData;
            }
            else
            {
                user.Image = null;
            }
            user.Worker.User = user;
            user.RolesUsers  = null;
            user.Worker      = null;
            NgProjectService.Save <User, int>(user);
            user.Projects = ProjectService.FindAll(t => t.UserId == user.Id).ToList();
            user.Image    = NgProjectService.FindByFunc <Image, int>(t => t.UserId == user.Id);
            var newuser = UserService
                          .Include(t => t.Email)
                          .Include(t => t.Creator)
                          .Include(t => t.Projects)
                          .Include(t => t.RolesUsers)
                          .Find(t => t.login == User.Identity.Name);

            newuser.Subscriber = SubscribeService.Include(t => t.ProjectSubscribers).Find(t => t.UserId == user.Id);
            newuser.Worker     = WorkerService
                                 .Include(t => t.Projects)
                                 .Include(t => t.SkillWorkers)
                                 .Find(s => s.UserId == user.Id);
            return(View("Edit", newuser));
        }
Beispiel #5
0
 public UserController(NgProjectService UserService)
 {
     this.NgProjectService = UserService;
 }
Beispiel #6
0
        public IActionResult All()
        {
            var model = NgProjectService.GetAllUsers();

            return(View(model));
        }
Beispiel #7
0
 public ParticipantController(ISomeModel someMethod, NgProjectService UserService)
 {
     this.someModel = someMethod;
 }