예제 #1
0
파일: GraphService.cs 프로젝트: ivancea/win
        public void AddGraph(GraphDto graphDto)
        {
            var graph = graphDtoToGraphMapping.Map(graphDto);

            winContext.Graphs.Add(graph);
            winContext.SaveChanges();
        }
예제 #2
0
        public ActionResult <WorkerDto> Add([FromBody] WorkerDto workerDto)
        {
            if (workerDto.UserName == null)
            {
                return(BadRequest(new { Password = "******" }));
            }

            if (workerDto.Password == null)
            {
                return(BadRequest(new { Password = "******" }));
            }

            Worker worker = workerDtoToWorkerMapping.Map(workerDto);

            User user = new User()
            {
                UserName     = workerDto.UserName,
                Worker       = worker,
                PasswordHash = securityService.HashPassword(workerDto.Password)
            };

            alohaContext.Users.Add(user);
            alohaContext.SaveChanges();

            return(workerToWorkerDtoMapping.Map(worker));
        }
예제 #3
0
        public UserDto GetById(int id)
        {
            User user = alohaContext.Users.Find(id);

            return(user == null
                ? null
                : userToUserDtoMapping.Map(user));
        }
예제 #4
0
        public OfficeDto Get(int id)
        {
            Office office = dbContext.Offices
                            .Single(o => o.Id == id);

            return(office == null
                ? null
                : officeToOfficeDtoMapping.Map(office));
        }
예제 #5
0
        public OfficeDto Add([FromBody] OfficeDto officeDto)
        {
            Office office = officeDtoToOfficeMapping.Map(officeDto);

            dbContext.Set <Office>()
            .Add(office);

            dbContext.SaveChanges();

            return(officeToOfficeDtoMapping.Map(office));
        }
예제 #6
0
        public WorkstationDto Get(int floorId, int id)
        {
            Workstation workstation = dbContext.Set <Workstation>()
                                      .Include(w => w.Floor)
                                      .Where(w => w.Floor.Id == floorId)
                                      .SingleOrDefault(w => w.Id == id);

            return(workstation == null
                ? null
                : workstationToWorkstationDtoMapping.Map(workstation));
        }
예제 #7
0
        public FloorDto Get(int id)
        {
            Floor floor = dbContext.Set <Floor>()
                          .Include(f => f.Office)
                          .Include(f => f.Workstations)
                          .Include(f => f.Image)
                          .Single(f => f.Id == id);

            return(floor == null
                ? null
                : floorToFloorDtoMapping.Map(floor));
        }
예제 #8
0
        public WorkerDto GetById(int id)
        {
            Worker worker = alohaContext.Workers
                            .Include(w => w.User)
                            .Include(w => w.Workstation)
                            .ThenInclude(w => w.Floor)
                            .Include(f => f.Photo)
                            .Single(w => w.Id == id);

            return(worker == null
                ? null
                : workerToWorkerDtoMapping.Map(worker));
        }
예제 #9
0
        public WorkstationDto Add(int floorId, [FromBody] WorkstationDto workstationDto)
        {
            Workstation workstation = workstationDtoToWorkstationMapping.Map(workstationDto);

            Floor floor = dbContext.Floors
                          .Include(o => o.Workstations)
                          .SingleOrDefault(o => o.Id == floorId);

            floor.Workstations.Add(workstation);

            dbContext.SaveChanges();

            return(workstationToWorkstationDtoMapping.Map(workstation));
        }
예제 #10
0
        public FloorDto Add([FromBody] FloorDto floorDto)
        {
            Floor floor = floorDtoToFloorMapping.Map(floorDto);

            Office office = dbContext.Offices
                            .Include(o => o.Floors)
                            .SingleOrDefault(o => o.Id == floorDto.OfficeId);

            office.Floors.Add(floor);

            dbContext.SaveChanges();

            return(floorToFloorDtoMapping.Map(floor));
        }
예제 #11
0
파일: GraphService.cs 프로젝트: ivancea/win
        public void AddConcept(int graphId, ConceptDto conceptDto)
        {
            var graph = winContext.Graphs
                        .SingleOrDefault(g => g.Id == graphId);

            var concept = conceptDtoToConceptMapping.Map(conceptDto);

            concept.Graph = graph;

            foreach (var dependency in winContext.Concepts
                     .Where(c => c.Graph.Id == graphId)
                     .Where(c => conceptDto.DependenciesIds.Contains(c.Id))
                     .ToList())
            {
                concept.Dependencies.Add(dependency);
            }

            winContext.Concepts.Add(concept);
            winContext.SaveChanges();
        }
예제 #12
0
파일: GraphService.cs 프로젝트: ivancea/win
        public GraphDto GetGraphById(int id)
        {
            var graph = winContext.Graphs
                        .SingleOrDefault(g => g.Id == id);

            if (graph == null)
            {
                return(null);
            }

            return(graphToGraphDtoMapping.Map(graph));
        }
예제 #13
0
        public UserDto Add([FromBody] UserDto userDto)
        {
            User user = userDtoToUserMapping.Map(userDto);

            user.PasswordHash = securityService.HashPassword("test");

            alohaContext.Users.Add(user);

            alohaContext.SaveChanges();

            return(userToUserDtoMapping.Map(user));
        }