public async Task <Response> Get() { try { string username = AuthenticationController.GetCurrentUsername(this.HttpContext); return(new Response(this.Response, this._userRepo.GetByUsername(username))); } catch (Exception error) { return(new Response(this.Response, new Error(HttpStatusCode.BadRequest, "Kan gebruiker ophalen: " + error.Message))); } }
public async Task <object> Create([FromBody] ProjectPost project) { try { project.LastEditedUser = this._userRepo.GetByUsername(AuthenticationController.GetCurrentUsername(this.HttpContext)).Id; project.LastEditedDate = DateTimeOffset.Now; project.LocationCode = this.GetLocation(project.Location.Longtitude, project.Location.Latitude).Id; this._repo.Add(project); return(new { success = true }); } catch (Exception error) { return(new Response(this.Response, new Error(HttpStatusCode.BadRequest, "Kan geen nieuw project aanmaken: " + error.Message))); } }
public async Task <Response> Put([FromBody] ProjectPost project) { try { User user = this._userRepo.GetByUsername(AuthenticationController.GetCurrentUsername(this.HttpContext)); if (user != null) { project.LastEditedUser = user.Id; } project.LastEditedDate = DateTimeOffset.Now; if (project.Location?.Latitude != null && project.Location.Longtitude != null) { project.LocationCode = this.GetLocation(project.Location.Longtitude, project.Location.Latitude).Id; } return(new Response(this.Response, this._repo.Edit(project))); } catch (Exception error) { return(new Response(this.Response, new Error(HttpStatusCode.BadRequest, "Kan project niet wijzigen: " + error.Message))); } }