public BaseWebServiceResponse Add(AddBrandViewModel model) { var brandDto = mapper.Map <AddBrandViewModel, BrandDTO>(model); var brandNameExists = _brandService.BrandNameExists(brandDto); var response = new BaseWebServiceResponse { ActionSuccessful = !brandNameExists, Error = brandNameExists ? new ErrorServiceViewModel() { Name = "Brand Name", Message = "Brand Name is already in use." } : null }; if (response.Error != null) { return(response); } var brandAdded = _brandService.Add(brandDto); if (!brandAdded) { response.ActionSuccessful = false; response.Error = brandAdded ? null : new ErrorServiceViewModel() { Name = "Brand", Message = "There was a problem creating the Brand. We have been notified of the error but please try again." }; } response.SuccessMessage = "Brand added successfully!"; response.ActionSuccessful = true; return(response); }