public async Task <ActionResult <PlaceGroup_PlaceGroupDTO> > Create([FromBody] PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(PlaceGroup_PlaceGroupDTO.Id)) { return(Forbid()); } PlaceGroup PlaceGroup = ConvertDTOToEntity(PlaceGroup_PlaceGroupDTO); PlaceGroup = await PlaceGroupService.Create(PlaceGroup); PlaceGroup_PlaceGroupDTO = new PlaceGroup_PlaceGroupDTO(PlaceGroup); if (PlaceGroup.IsValidated) { return(PlaceGroup_PlaceGroupDTO); } else { return(BadRequest(PlaceGroup_PlaceGroupDTO)); } }
public async Task <ActionResult <PlaceGroup_PlaceGroupDTO> > Get([FromBody] PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(PlaceGroup_PlaceGroupDTO.Id)) { return(Forbid()); } PlaceGroup PlaceGroup = await PlaceGroupService.Get(PlaceGroup_PlaceGroupDTO.Id); return(new PlaceGroup_PlaceGroupDTO(PlaceGroup)); }
private PlaceGroup ConvertDTOToEntity(PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { PlaceGroup PlaceGroup = new PlaceGroup(); PlaceGroup.Id = PlaceGroup_PlaceGroupDTO.Id; PlaceGroup.ParentId = PlaceGroup_PlaceGroupDTO.ParentId; PlaceGroup.Name = PlaceGroup_PlaceGroupDTO.Name; PlaceGroup.Code = PlaceGroup_PlaceGroupDTO.Code; PlaceGroup.Parent = PlaceGroup_PlaceGroupDTO.Parent == null ? null : new PlaceGroup { Id = PlaceGroup_PlaceGroupDTO.Parent.Id, ParentId = PlaceGroup_PlaceGroupDTO.Parent.ParentId, Name = PlaceGroup_PlaceGroupDTO.Parent.Name, Code = PlaceGroup_PlaceGroupDTO.Parent.Code, }; PlaceGroup.BaseLanguage = CurrentContext.Language; return(PlaceGroup); }