//create department /// <summary> /// entity to add: Department /// </summary> /// <param name="departmentCreateRequest"></param> /// <returns></returns> public static Department MapFromDepartmentCreateRequestToDepartment(DepartmentCreateRequest departmentCreateRequest) { Department department = new Department { Name = departmentCreateRequest.Name }; return(department); }
public async Task <IActionResult> Create([FromBody] DepartmentCreateRequest requestModel) { //map to entity Department department = DepartmentMapper.MapFromDepartmentCreateRequestToDepartment(requestModel); db.Departments.Add(department); await db.SaveChangesAsync(); logger.Here().Information("Created department successfully"); return(CreatedAtRoute("GetDepartmentById", new { id = department.DepartmentId }, null)); }
public DepartmentCreateResponse Create(DepartmentCreateRequest request) { var apiurl = string.Format(Urls.DepartmentCreate, request.ACCESS_TOKEN); var rtn = RequestHelper.Post <DepartmentCreateResponse>(apiurl, request); if (rtn.ErrCode != ErrCodeEnum.OK) { throw new ApiException(ApiCodeEnum.Error, rtn.ErrMsg); } return(rtn); }
public async Task <ApiSuccessResponse> CreateAsync(DepartmentCreateRequest request) { var department = new Department() { Name = request.Name, Code = request.Code }; await _unitOfWork.DepartmentRepository.CreateAsync(department); if (await _unitOfWork.AppSaveChangesAsync()) { return new ApiSuccessResponse() { StatusCode = 200, Message = "The department has been created successfully." } } ; throw new MyAppException("Something went wrong!"); }
public DepartmentCreateResponse Create(DepartmentCreateRequest request) { return(_departmentAppService.Create(request)); }
public DepartmentCreateResponse Post(DepartmentCreateRequest request) { var rtn = _departmentApiService.Create(request); return(rtn); }
public async Task <IActionResult> Create(DepartmentCreateRequest request) { return(Ok(await _departmentService.CreateAsync(request))); }