public IActionResult Create(ExperienceCreateViewModel experienceCreateVM) { if (ModelState.IsValid)// { var product = new Product { ProductName = experienceCreateVM.ProductName, CategoryID = int.Parse(experienceCreateVM.CategoryID) }; var addedProduct = _productRepository.AddProduct(product); string uniqueFileName = PhotoHelper.SaveImageAndReturnUniqueFileName(experienceCreateVM.Photo, _hostingEnvironment, "images/products"); var experience = new Experience { ProductID = addedProduct.ProductID, Evaluation = experienceCreateVM.Evaluation, Describe = experienceCreateVM.Describe, Recommendation = experienceCreateVM.Recommendation, UserName = User.FindFirst(ClaimTypes.Name).Value, PhotoPath = uniqueFileName, Date = DateTime.Now }; var addedExperience = _experienceRepository.AddExperience(experience); return(RedirectToAction("details", new { experienceID = addedExperience.ExperienceID })); } return(View()); }
public async Task AddExperience(Experience model, int resumeId) { var resume = await _resumeRepository.FindResume(resumeId); model.Resume = resume; if (model.NotFinished) { model.YearTo = 0; } await _experienceRepository.AddExperience(model); }
public async Task <IActionResult> AddExperience([FromBody] Experience experience) { var _experience = await _experienceRepository.AddExperience(experience); if (_experience == null) { return(NotFound("Experiência não encontrada")); } else { return(Ok(_experience)); } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Experience experience; if (Id.HasValue) { experience = _experienceRepository.GetExperienceById(Id.Value); } else { experience = new Experience(); } if (Input.Date != experience.Date) { experience.Date = Input.Date; } if (Input.Title != experience.Title) { experience.Title = Input.Title; } if (Input.Description != experience.Description) { experience.Description = Input.Description; } if (Input.Sector != experience.Sector) { experience.Sector = Input.Sector; } if (Input.CompanyId != experience.CompanyId) { experience.CompanyId = Input.CompanyId; } if (Input.Staff != experience.Staff) { experience.Staff = Input.Staff; } if (Input.Duration != experience.Duration) { experience.Duration = Input.Duration; } if (Id.HasValue) { _experienceRepository.UpdateExperience(experience); _experienceRepository.UpdateExperienceKeywords(Id.Value, Input.SelectedKeywordIds); } else { var exp = await _experienceRepository.AddExperience(experience); _experienceRepository.UpdateExperienceKeywords(exp.Id, Input.SelectedKeywordIds); } StatusMessage = "Experience created/updated"; return(RedirectToPage("Index")); }