public async Task <ActionResult> ProjectCreation(ProjectCreationBindingModel model) { var response = await _dataClient.GetProjectCategories(); if (response.StatusIsSuccessful) { if (response.Data != null) { model.Categories = response.Data.ToList().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }); } } if (!ModelState.IsValid) { } model.UserId = _tokenContainer.UserId.Value; var responseCreate = await _dataClient.Createproject(model); //return View(model); if (responseCreate.StatusIsSuccessful) { TempData["Success"] = "Added Successfully!"; } else { TempData["Error"] = "Did not add project"; } return(RedirectToAction("ProjectCreation", "Projects")); }
public HttpResponseMessage CreateProject(ProjectCreationBindingModel model) { var project = new Project() { Name = model.Name, Description = model.Description, CreationDate = DateTime.UtcNow, EndDate = model.EndDate, TargetAmount = model.TargetAmount, UserId = model.UserId, CategoryId = model.CategoryId, Image = model.Image, Video = model.Video, GlobalId = Guid.NewGuid().ToString(), }; _repository.CreateProject(project); return(Request.CreateResponse(HttpStatusCode.OK)); }
async Task <ProjectsResponse> IDataClient.Createproject(ProjectCreationBindingModel model) { var projectModel = new ProjectCreationBindingModel { Name = model.Name, Image = model.Image, CategoryId = model.CategoryId, CreationDate = DateTime.Now, EndDate = model.EndDate, TargetAmount = model.TargetAmount, Description = model.Description, Video = model.Video, UserId = model.UserId }; var response = await ApiClient.PostJsonEncodedContent(projectCreateUri, projectModel); var createprojectResponse = await CreateJsonResponse <ProjectsResponse>(response); return(createprojectResponse); }
public async Task <ActionResult> ProjectCreation() { var response = await _dataClient.GetProjectCategories(); var model = new ProjectCreationBindingModel(); if (response.StatusIsSuccessful) { if (response.Data != null) { model.Categories = response.Data.ToList().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }); } } if (response.ResponseCode == System.Net.HttpStatusCode.Unauthorized) { return(RedirectToAction("Login", "Account")); } return(View(model)); }