public CareerDto EditCareer(CareerDto careerDto, int userId, int tenantId) { var careerObj = _careerService.Query(x => x.CareerId == careerDto.CareerId && x.TenantId == tenantId).Select().FirstOrDefault(); if (careerObj == null) { throw new NotFoundException(ErrorCodes.ProductNotFound); } ValidateCareer(careerDto, tenantId); careerObj.Title = careerDto.Title; careerObj.Description = careerDto.Description; careerObj.IsDeleted = careerDto.IsDeleted; _careerService.Update(careerObj); SaveChanges(); return(careerDto); }
public IActionResult Edit(int id, CareerViewModel model) { var career = _careerService.GetById(id); if (career == null) { return(BadRequest()); } if (ModelState.IsValid) { model.ToEntityModel(career); _careerService.Update(career); return(Json(new { success = true })); } return(Json(new { success = false, data = model, errors = ModelState.Values.Where(i => i.Errors.Count > 0).Select(x => x.Errors) })); }
public async Task <ActionResult> Edit(int id, CareerViewModel careerViewModel) { var temp = await _careerService.FindById(id); var existingCode = await _careerService.FindByCode(careerViewModel.Code); if (existingCode == null || existingCode.Code == temp.Code) { var career = new Career { Name = careerViewModel.Name, Code = careerViewModel.Code, FacultyId = careerViewModel.FacultyId }; await _careerService.Update(id, career); return(Ok()); } else { return(BadRequest("Ya existe una carrera con ese codigo")); } }