public IActionResult CreateTrackingTypes(TrackingTypeVM trackingTypeVM, IFormFile FilePicture) { try { PictureVM imageEntity = GeneratePicture.CreatePicture(FilePicture, $"{trackingTypeVM.Description}"); trackingTypeVM.Picture = imageEntity; _boxTrackingApplicationService.AddTraceType(trackingTypeVM); return(RedirectToAction("TrackingTypes")); } catch (CustomException exc) { throw exc; } catch (Exception ex) { throw ex; } }
public void AddTraceType(TrackingTypeVM entity) { try { var traceType = _mapper.Map <TrackingType>(entity); //if (!boxType.ComponentValidator.Validate(boxType, new BoxTypeValidator())) //{ // throw new CustomException(string.Join(", ", boxType.ComponentValidator.ValidationResult.Errors.Select(x => x.ErrorMessage))); //} _unitOfWork.Repository <TrackingType>().Add(traceType); _unitOfWork.CommitSync(); } catch (CustomException exc) { throw exc; } catch (Exception ex) { throw CustomException.Create <TrackingApplicationService>("Unexpected error fetching add trace type", nameof(this.AddTraceType), ex); } }