public async Task <IActionResult> Post([FromBody] LecturerBase lecturer) { try { if (lecturer.UserId != this.GetAuthenticatedUserId()) { this._logger.Log(LogHelper.CreateLog( DateTime.Now, LogType.Fail, Constants.ForbiddenLectureCreation, null)); return(this.Forbid()); } var result = (Error)await this._dm.OperateAsync <LecturerBase, object>( Constants.CreateLecturerProfile, lecturer); if (result == Error.LecturerAlreadyExists) { this._logger.Log(LogHelper.CreateLog( DateTime.Now, LogType.Fail, Constants.LecturerAlreadyExists, null)); return(this.BadRequest(Constants.LecturerAlreadyExists)); } return(this.Ok($"Lecturer ID : {(int)result}")); } catch (Exception ex) { this._logger.Log(LogHelper.CreateLog( DateTime.Now, LogType.Fatal, Constants.LecturerCreationUnknownError, ex)); return(this.BadRequest(Constants.LecturerCreationUnknownError)); } }
public async Task <Response <string> > AddLecturerProfileAsync(LecturerBase lecturer) { return(await this.SendPostRequest(LECTURERS_URI, lecturer)); }