public IActionResult Post(CreateViewModels model) { if (this.ModelState.IsValid) { Checkin checkin = model.ToEntity(); var repo = this.Storage.GetRepository <ICheckinRepository>(); repo.Create(checkin, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }
public async Task <IActionResult> Post(CreateViewModels viewModel) { if (this.ModelState.IsValid) { Checkin entity = viewModel.ToEntity(); var repo = this.Storage.GetRepository <ICheckinRepository>(); var imageUrl = await _imageService.UploadImageAsync(viewModel.Image); entity.ImageUrl = imageUrl.ToString(); repo.Create(entity, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }