public async Task <IActionResult> DeleteOneExperience([FromRoute] Guid id) { // retrieve user to delete, if user does not exist return error var exprToDelete = await _experienceRepository.GetFirstByExpressionAsync(x => x.Id == id); if (exprToDelete == null) { var err = new ErrorObject() { Method = "DELETE", At = $"/api/experiences/{id}", StatusCode = 404, Error = "Could not find experience to delete" }; return(NotFound(err)); } // delete the experience from the database _experienceRepository.Delete(exprToDelete); if (!await _experienceRepository.SaveAsync()) { var errMsg = "Error deleting an experience"; _logger.Error(errMsg); var err = new ErrorObject() { Method = "DELETE", At = $"/api/experiences/{id}", StatusCode = 500, Error = errMsg }; return(StatusCode(500, err)); } return(NoContent()); }
public async Task Delete(int id) { var entity = await GetById(id); if (entity == null) { throw new ArgumentNullException(nameof(entity)); } await _repository.Delete(entity); }
public IActionResult Delete(int id) { var experience = experienceRepository.GetById(id); if (experience == null) { return(NotFound()); } experienceRepository.Delete(experience); unitofwork.commit(); return(NoContent()); }
public async Task <IActionResult> DeleteExperience(int id) { Experience experience = await _experienceRepository.FindAsync(id); if (experience == null) { return(NotFound()); } _experienceRepository.Delete(experience); return(NoContent()); }
public DataModel.Response.BaseResponse Delete(string id) { try { IExperienceRepository experienceRepository = RepositoryClassFactory.GetInstance().GetExperienceRepository(); experienceRepository.Delete(id); return(new BaseResponse { ErrorCode = (int)ErrorCode.None, Message = Resources.Resource.msg_delete_success }); } catch (Exception ex) { return(new BaseResponse { ErrorCode = (int)ErrorCode.Error, Message = ex.Message }); } }
public IActionResult DeleteExperience([FromQuery] int expId) { var lang = Request.Headers["language"].ToString(); var errorMessages = new List <string>(); try { var exp = _experienceRepository.FindById(expId); if (exp == null) { return(NotFound()); } var deletedExperience = _experienceRepository.Delete(expId); return(Ok(new { deletedExperienceId = deletedExperience.Id })); } catch { errorMessages.Add(_translator.GetTranslation("ERROR", lang)); return(BadRequest(new { errors = errorMessages })); } }
public void DeleteExperience(Experience experience) { experienceRepository.Delete(experience); }
public void Delete(Experience entity) { _ExperienceRepository.Delete(entity); }
public void Update(UserCreateModel model) { var entity = UserManager.FindById(model.Id); entity.UserName = model.Email; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Email = model.Email; entity.PhoneNumber = model.PhoneNumber; entity.Address = model.Address; entity.Others = model.Others; entity.Website = model.Website; entity.Files = ManageFiles(model); #region Manage Educations foreach (var m in model.Educations.Where(m => string.IsNullOrEmpty(m.UserId))) { m.UserId = model.Id; } foreach (var education in model.Educations) { _educationRepository.InsertOrUpdate(_modelFactory.MapToDomain <EducationModel, Education>(education, null)); } foreach (var m in entity.Educations.Where(y => model.Educations.FirstOrDefault(x => x.Id == y.Id) == null)) { _educationRepository.Delete(m.Id); } _educationRepository.Save(); #endregion #region Manage Experiences foreach (var m in model.Experiences.Where(m => string.IsNullOrEmpty(m.UserId))) { m.UserId = model.Id; } foreach (var m in model.Experiences) { _experienceRepository.InsertOrUpdate(_modelFactory.MapToDomain <ExperienceModel, Experience>(m, null)); } foreach (var m in entity.Experiences.Where(y => model.Experiences.FirstOrDefault(x => x.Id == y.Id) == null)) { _experienceRepository.Delete(m.Id); } _experienceRepository.Save(); #endregion #region Manage Projects foreach (var m in model.Projects.Where(m => string.IsNullOrEmpty(m.UserId))) { m.UserId = model.Id; } foreach (var m in model.Projects) { _projectRepository.InsertOrUpdate(_modelFactory.MapToDomain <ProjectModel, Project>(m, null)); } foreach (var m in entity.Projects.Where(y => model.Projects.FirstOrDefault(x => x.Id == y.Id) == null)) { _projectRepository.Delete(m.Id); } _projectRepository.Save(); #endregion #region Manage Skills foreach (var m in model.Skills.Where(m => string.IsNullOrEmpty(m.UserId))) { m.UserId = model.Id; } foreach (var m in model.Skills) { _skillRepository.InsertOrUpdate(_modelFactory.MapToDomain <SkillModel, Skill>(m, null)); } foreach (var m in entity.Skills.Where(y => model.Skills.FirstOrDefault(x => x.Id == y.Id) == null)) { _skillRepository.Delete(m.Id); } _skillRepository.Save(); #endregion UserManager.Update(entity); }