public void AddGraph(GraphDto graphDto) { var graph = graphDtoToGraphMapping.Map(graphDto); winContext.Graphs.Add(graph); winContext.SaveChanges(); }
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)); }
public UserDto GetById(int id) { User user = alohaContext.Users.Find(id); return(user == null ? null : userToUserDtoMapping.Map(user)); }
public OfficeDto Get(int id) { Office office = dbContext.Offices .Single(o => o.Id == id); return(office == null ? null : officeToOfficeDtoMapping.Map(office)); }
public OfficeDto Add([FromBody] OfficeDto officeDto) { Office office = officeDtoToOfficeMapping.Map(officeDto); dbContext.Set <Office>() .Add(office); dbContext.SaveChanges(); return(officeToOfficeDtoMapping.Map(office)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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(); }
public GraphDto GetGraphById(int id) { var graph = winContext.Graphs .SingleOrDefault(g => g.Id == id); if (graph == null) { return(null); } return(graphToGraphDtoMapping.Map(graph)); }
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)); }