Ejemplo n.º 1
0
        public static User DtoToEntity(UserDto dto, MainDBModelContainer db)
        {
            var entity = new User
            {
                Username     = dto.Username,
                Passkey      = dto.Passkey,
                Email        = dto.Email,
                Firstname    = dto.Firstname,
                DateOfBirth  = dto.DateOfBirth,
                LastActivity = dto.LastActivity,
                Roles        = dto.Roles
            };

            if (dto.TeamId != 0)
            {
                entity.Team = db.TeamSet.Find(dto.TeamId);
            }

            if (dto.TaskId != 0)
            {
                entity.Task_Id = dto.TaskId;
            }

            return(entity);
        }
Ejemplo n.º 2
0
        public static void Update(UserDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newUserData = UserMapper.DtoToEntity(dto, db);
                var oldUserData = db.UserSet.Find(dto.Id);
                if (oldUserData != null)
                {
                    oldUserData.Username     = newUserData.Username;
                    oldUserData.Passkey      = newUserData.Passkey;
                    oldUserData.Email        = newUserData.Email;
                    oldUserData.Firstname    = newUserData.Firstname;
                    oldUserData.DateOfBirth  = newUserData.DateOfBirth;
                    oldUserData.LastActivity = newUserData.LastActivity;
                    oldUserData.Roles        = newUserData.Roles;
                    oldUserData.Team         = newUserData.Team;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 3
0
        public static void Update(TaskDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = TaskMapper.DtoToEntity(dto, db);
                var oldData = db.TaskSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Slug         = newData.Slug;
                    oldData.Name         = newData.Name;
                    oldData.Description  = newData.Description;
                    oldData.CreatedOn    = newData.CreatedOn;
                    oldData.Estimate     = newData.Estimate;
                    oldData.EndDate      = newData.EndDate;
                    oldData.Project      = newData.Project;
                    oldData.Milestone    = newData.Milestone;
                    oldData.TaskStatus   = newData.TaskStatus;
                    oldData.TaskPriority = newData.TaskPriority;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 4
0
        public static void Update(ProjectDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = ProjectMapper.DtoToEntity(dto, db);
                var oldData = db.ProjectSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Name           = newData.Name;
                    oldData.CreatedOn      = newData.CreatedOn;
                    oldData.ProjectManager = newData.ProjectManager;
                    oldData.ProjectStatus  = newData.ProjectStatus;
                    oldData.Client1        = newData.Client1;
                    oldData.Status         = newData.ProjectStatus.Name;
                    oldData.Client         = newData.Client1.Name;

                    oldData.Team = newData.Team;
                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 5
0
        public static List <ClientDto> ReadAll()
        {
            using (var db = new MainDBModelContainer())
            {
                var list = db.ClientSet.ToList();

                return(list.Select(ClientMapper.EntityToDto).ToList());
            }
        }
Ejemplo n.º 6
0
        public static List <ProjectStatusDto> ReadAll()
        {
            using (var db = new MainDBModelContainer())
            {
                var list = db.ProjectStatusSet.ToList();

                return(list.Select(ProjectStatusMapper.EntityToDto).ToList());
            }
        }
Ejemplo n.º 7
0
        public static List <TaskPriorityDto> ReadAll()
        {
            using (var db = new MainDBModelContainer())
            {
                var list = db.TaskPrioritySet.ToList();

                return(list.Select(TaskPriorityMapper.EntityToDto).ToList());
            }
        }
Ejemplo n.º 8
0
        public static List <MilestoneDto> ReadAll()
        {
            using (var db = new MainDBModelContainer())
            {
                var list = db.MilestoneSet.ToList();

                return(list.Select(MilestoneMapper.EntityToDto).ToList());
            }
        }
Ejemplo n.º 9
0
        public static void Create(MilestoneDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = MilestoneMapper.DtoToEntity(dto, db);

                db.MilestoneSet.Add(entity);
                db.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public static void Create(UserDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = UserMapper.DtoToEntity(dto, db);

                db.UserSet.Add(entity);
                db.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        public static void Delete(int id)
        {
            using (var db = new MainDBModelContainer())
            {
                var toDelete = db.ProjectSet.Find(id);

                db.ProjectSet.Remove(toDelete);
                db.SaveChanges();
            }
        }
Ejemplo n.º 12
0
        public static void Create(ClientDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = ClientMapper.DtoToEntity(dto);

                db.ClientSet.Add(entity);
                db.SaveChanges();
            }
        }
Ejemplo n.º 13
0
        public static void Create(TaskPriorityDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = TaskPriorityMapper.DtoToEntity(dto);

                db.TaskPrioritySet.Add(entity);
                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public static void Create(ProjectDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = ProjectMapper.DtoToEntity(dto, db);

                db.ProjectSet.Add(entity);
                db.SaveChanges();
            }
        }
Ejemplo n.º 15
0
 public static ClientDto Read(int id)
 {
     using (var db = new MainDBModelContainer())
     {
         var data = db.ClientSet.Find(id);
         if (data != null)
         {
             return(ClientMapper.EntityToDto(data));
         }
         throw new ElementNotFoundException();
     }
 }
Ejemplo n.º 16
0
 public static void Delete(int id)
 {
     using (var db = new MainDBModelContainer())
     {
         var toDelete = db.ClientSet.Find(id);
         if (toDelete != null)
         {
             db.ClientSet.Remove(toDelete);
             db.SaveChanges();
         }
         else
         {
             throw new ElementNotFoundException();
         }
     }
 }
Ejemplo n.º 17
0
        public static Commit DtoToEntity(CommitDto dto, MainDBModelContainer db)
        {
            var entity = new Commit
            {
                Id             = dto.Id,
                CommitHash     = dto.CommitHash,
                CommitDateTime = dto.CommitDateTime
            };

            if (dto.TaskId != 0)
            {
                var task = db.TaskSet.Find(dto.TaskId);
                entity.Task = task;
            }

            return(entity);
        }
Ejemplo n.º 18
0
        public static void Update(TaskStatusDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = TaskStatusMapper.DtoToEntity(dto);
                var oldData = db.TaskStatusSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Name = newData.Name;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 19
0
        public static Milestone DtoToEntity(MilestoneDto dto, MainDBModelContainer db)
        {
            var entity = new Milestone
            {
                Id      = dto.Id,
                Name    = dto.Name,
                EndDate = dto.EndDate
            };


            if (dto.ProjectId != 0)
            {
                var project = db.ProjectSet.Find(dto.ProjectId);
                entity.Project = project;
            }

            return(entity);
        }
Ejemplo n.º 20
0
        public static TaskLog DtoToEntity(TaskLogDto dto, MainDBModelContainer db)
        {
            var entity = new TaskLog
            {
                Id        = dto.Id,
                Event     = dto.Event,
                EntryDate = dto.EntryDate
            };


            if (dto.TaskId != 0)
            {
                var task = db.TaskSet.Find(dto.TaskId);
                entity.Task = task;
            }

            return(entity);
        }
Ejemplo n.º 21
0
        public static void Update(RoleDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = RoleMapper.DtoToEntity(dto);
                var oldData = db.RoleSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.FriendlyName = newData.FriendlyName;
                    oldData.SysRole      = newData.SysRole;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 22
0
        public static void Update(MilestoneDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = MilestoneMapper.DtoToEntity(dto, db);
                var oldData = db.MilestoneSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Name    = newData.Name;
                    oldData.EndDate = newData.EndDate;
                    oldData.Project = newData.Project;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 23
0
        public static void Update(ClientDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = ClientMapper.DtoToEntity(dto);
                var oldData = db.ClientSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Name  = newData.Name;
                    oldData.Email = newData.Email;
                    oldData.Phone = newData.Phone;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 24
0
        public static void Update(CommitDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = CommitMapper.DtoToEntity(dto, db);
                var oldData = db.CommitSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.CommitHash     = newData.CommitHash;
                    oldData.CommitDateTime = newData.CommitDateTime;
                    oldData.Task           = newData.Task;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 25
0
        public static void Update(TaskLogDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = TaskLogMapper.DtoToEntity(dto, db);
                var oldData = db.TaskLogSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.Event     = newData.Event;
                    oldData.EntryDate = newData.EntryDate;
                    oldData.Task      = newData.Task;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }
Ejemplo n.º 26
0
        public static Project DtoToEntity(ProjectDto dto, MainDBModelContainer db)
        {
            var entity = new Project
            {
                Id             = dto.Id,
                Name           = dto.Name,
                CreatedOn      = dto.CreatedOn,
                ProjectManager = dto.ProjectManager,
            };


            if (dto.ProjectStatusId != 0)
            {
                var status = db.ProjectStatusSet.Find(1);
                entity.Status        = status.Name;
                entity.ProjectStatus = status;
            }
            else
            {
                entity.Status        = "pradėtas";
                entity.ProjectStatus = db.ProjectStatusSet.Find(1);
            }

            var teams = db.TeamSet.Find(dto.TeamIds);
            var col   = new Collection <Team>();

            col.Add(teams);
            entity.Team = col;

            if (dto.ClientId != 0)
            {
                var client = db.ClientSet.Find(dto.ClientId);
                entity.Client  = client.Name;
                entity.Client1 = client;
            }



            return(entity);
        }
Ejemplo n.º 27
0
        public static Task DtoToEntity(TaskDto dto, MainDBModelContainer db)
        {
            var entity = new Task
            {
                Id          = dto.Id,
                Slug        = dto.Slug,
                Name        = dto.Name,
                Description = dto.Description,
                CreatedOn   = dto.CreatedOn,
                Estimate    = dto.Estimate,
                EndDate     = dto.EndDate
            };

            if (dto.ProjectId != 0)
            {
                var project = db.ProjectSet.Find(dto.ProjectId);
                entity.Project = project;
            }

            if (dto.MilestoneId != 0)
            {
                var milestone = db.MilestoneSet.Find(dto.MilestoneId);
                entity.Milestone = milestone;
            }

            if (dto.TaskStatusId != 0)
            {
                var taskStatus = db.TaskStatusSet.Find(dto.TaskStatusId);
                entity.TaskStatus = taskStatus;
            }

            if (dto.TaskPriorityId != 0)
            {
                var taskPriority = db.TaskPrioritySet.Find(dto.TaskPriorityId);
                entity.TaskPriority = taskPriority;
            }

            return(entity);
        }