예제 #1
0
        public ActionResult <PostReadDto> CreatePost(PostCreateDto post)
        {
            var postModel = _mapper.Map <Post>(post);

            _repository.CreatePost(postModel);
            _repository.SaveChanges();
            return(Ok(postModel));
        }
        public ActionResult <GuildReadDto> CreateGuild(GuildCreateDto guild)
        {
            var guildModel = _mapper.Map <Guild>(guild);

            _repository.CreateGuild(guildModel);
            _repository.SaveChanges();
            return(StatusCode(201, _mapper.Map <GuildReadDto>(guildModel)));
        }
        public ActionResult <ProjectReadDto> AddProject(ProjectCreateDto newProject)
        {
            var project = _mapper.Map <Project>(newProject);

            _repo.AddProject(project);
            _repo.SaveChanges();
            var newSlot = new ProjectSlot {
                ProjectId = project.Id, Role = "Chef de projet"
            };

            _repo.AddProjectSlot(newSlot);
            _repo.SaveChanges();
            _repo.AddProjectMember(new ProjectMember {
                ProjectId = project.Id, SlotId = newSlot.Id, UserId = newProject.UserId
            });
            return(Ok(_mapper.Map <ProjectReadDto>(project)));
        }