public CommonResult <IQueryable <DrinksInfoDto> > GetDrinksList() { IQueryable <DrinksInfoDto> DrinksList; if (_db.Drinks.Any()) { return(CommonResult <IQueryable <DrinksInfoDto> > .Failure <IQueryable <DrinksInfoDto> >("No drinks Yet...")); } try { DrinksList = from a in _db.Drinks join b in _db.Locations on a.LocationOfDrinkId equals b.Id join c in _db.DrinkTypes on a.DrinkTypeId equals c.Id select new DrinksInfoDto { Name = a.Name, Price = a.Price, Type = c.Name, Location = b.Name }; } catch (Exception ex) { return(CommonResult <IQueryable <DrinksInfoDto> > .Failure <IQueryable <DrinksInfoDto> >("Something Wrong with Db" + ex.Message)); } return(CommonResult <IQueryable <DrinksInfoDto> > .Success(DrinksList)); }
public async Task <CommonResult> Add(UserRatingDto ratingDto) { if (string.IsNullOrEmpty(ratingDto.Feedback)) { return(CommonResult.Failure("Cannot create user without field provided.")); } if (string.IsNullOrEmpty(ratingDto.UserAssessorId)) { return(CommonResult.Failure("Cannot create user without userAssessorId provided.")); } if (string.IsNullOrEmpty(ratingDto.UserEvaluatedId)) { return(CommonResult.Failure("Cannot create user without userEvaluatedId provided.")); } if (Enum.IsDefined(typeof(StarNumberType), ratingDto.StarType)) { return(CommonResult.Failure("Wrong enum value.")); } await _ratingsRepository.Add(ratingDto); return(CommonResult.Success()); }
/*----------------------*/ public CommonResult <IEnumerable <LocationFormDto> > ShowBarsInformaiton(string sortOrder, string searchString = null) { if (_db.Locations.Count() == 0) { return(CommonResult <IEnumerable <LocationFormDto> > .Failure <IEnumerable <LocationFormDto> > ("The DB does not contain any location yet...")); } var adapter = new SqlDataAdapter(); var con = new SqlConnection(); con.ConnectionString = ConnectionString; var select = new SqlCommand("SELECT Id, Name, Address, Latitude, Longitude" + " FROM Locations", con); // select.Parameters.AddWithValue("@Name", searchString); adapter.SelectCommand = select; var ds = new DataSet(); adapter.Fill(ds, "Locations"); var table = ds.Tables[0]; var data = _sorting.Mapping(table, searchString).ToList(); return(CommonResult <IEnumerable <LocationFormDto> > .Success(_sorting.SortByQuery(data , sortOrder))); }
public async Task <CommonResult <ExperianceDto> > GetById(int id) { var person = await _experiancesRepository.GetById(id); if (person == null) { return(CommonResult <ExperianceDto> .Failure <ExperianceDto>("Problem occured during fetching project with given id.")); } return(CommonResult <ExperianceDto> .Success(person)); }
public async Task <CommonResult <UserWorkPhotoDto> > GetById(int id) { var photoDto = await _photosOfWorkRepository.GetById(id); if (photoDto == null) { return(CommonResult <UserWorkPhotoDto> .Failure <UserWorkPhotoDto>("Problem occured during fetching photo url with given id.")); } return(CommonResult <UserWorkPhotoDto> .Success(photoDto)); }
public async Task <CommonResult <ApplicationUserDto> > GetUser(string id) { var person = await _personRepository.GetUser(id); if (person == null || person.IsDeleted) { return(CommonResult <ApplicationUserDto> .Failure <ApplicationUserDto>("Problem occured during fetching project with given id.")); } return(CommonResult <ApplicationUserDto> .Success(person)); }
public async Task <CommonResult <QualificationDto> > GetUser(int id) { var person = await _qualificationsRepository.GetById(id); if (person == null) { return(CommonResult <QualificationDto> .Failure <QualificationDto>("Problem occured during fetching qualification with given id.")); } return(CommonResult <QualificationDto> .Success(person)); }
public async Task <CommonResult> Update(ExperianceDto experianceDto) { var updateExperianceDto = await _experiancesRepository.Update(experianceDto); if (updateExperianceDto == null) { return(CommonResult <ExperianceDto> .Failure <ExperianceDto>("Problem occured updating entity.")); } return(CommonResult <ExperianceDto> .Success(experianceDto)); }
public async Task <CommonResult> Update(ApplicationUserDto user) { var updateApplicationUserDto = await _personRepository.UpdateUser(user); if (updateApplicationUserDto == null || updateApplicationUserDto.IsDeleted) { return(CommonResult <ApplicationUserDto> .Failure <ApplicationUserDto>("Problem occured updating entity.")); } return(CommonResult <ApplicationUserDto> .Success(user)); }
public async Task <CommonResult> Update(UserWorkPhotoDto photoDto) { var updateApplicationUserDto = await _photosOfWorkRepository.Update(photoDto); if (updateApplicationUserDto == null) { return(CommonResult <UserWorkPhotoDto> .Failure <UserWorkPhotoDto>("Problem occured updating entity.")); } return(CommonResult <UserWorkPhotoDto> .Success(photoDto)); }
public async Task <CommonResult> Add(ExperianceDto experianceDto) { if (await CheckIfExperianceAlreadyExist(experianceDto.UserId, experianceDto.ExperianceType)) { return(CommonResult.Failure("This experiance User already has")); } await _experiancesRepository.Add(experianceDto); return(CommonResult.Success()); }
public async Task <CommonResult> Update(QualificationDto qualificationDto) { var updateQualificationDto = await _qualificationsRepository.Update(qualificationDto); if (updateQualificationDto == null) { return(CommonResult <QualificationDto> .Failure <QualificationDto>("Problem occured updating entity.")); } return(CommonResult <QualificationDto> .Success(qualificationDto)); }
public CommonResult <ProjectDto> GetById(int id) { var project = _projectsRepository.GetById(id); if (project == null || project.IsDeleted) { return(CommonResult <ProjectDto> .Failure <ProjectDto>("Problem occured during fetching project with given id.")); } else { return(CommonResult <ProjectDto> .Success <ProjectDto>(project)); } }
public async Task <CommonResult> Add(UserWorkPhotoDto experianceDto) { if (string.IsNullOrEmpty(experianceDto.ApplicationUserId)) { return(CommonResult.Failure("Empty user Id")); } if (string.IsNullOrEmpty(experianceDto.PhotoUrl)) { return(CommonResult.Failure("Cannot create photo without its url address")); } await _photosOfWorkRepository.Add(experianceDto); return(CommonResult.Success()); }
public async Task <CommonResult> Add(QualificationDto qualificationDto) { if (string.IsNullOrEmpty(qualificationDto.QualificationField)) { return(CommonResult.Failure("Cannot create user without field provided.")); } if (string.IsNullOrEmpty(qualificationDto.ApplicationUserId)) { return(CommonResult.Failure("Cannot create user without user Id provided.")); } await _qualificationsRepository.Add(qualificationDto); return(CommonResult.Success()); }
public CommonResult Add(AddProjectDto project) { if (string.IsNullOrEmpty(project.Name)) { return(CommonResult.Failure("Cannot create project without name provided")); } if (string.IsNullOrEmpty(project.Description)) { return(CommonResult.Failure("Cannot create project without description provided")); } var existingProject = _projectRepository.GetByName(project.Name); if (existingProject != null && existingProject.IsDeleted == false && existingProject.Name == project.Name) { return(CommonResult.Failure("Project name already exists")); } _projectRepository.Add(project); return(CommonResult.Success()); }
public CommonResult Add(DrinkDto item) { if (string.IsNullOrEmpty(item.Name)) { return(CommonResult.Failure("No Name is declared")); } if (item.Price <= 0) { return(CommonResult.Failure("Price is not declared or less or equal then zero!")); } if (item.DrinkTypeId <= 0 || item.LocationOfDrinkId <= 0) { return(CommonResult.Failure("Wrong data with dropdown element")); } _repository.Add(item); return(CommonResult.Success()); }
public CommonResult Add(AddProjectDto project) { if (String.IsNullOrWhiteSpace(project.Name)) { return(CommonResult.Failure("Project name is empty.")); } if (String.IsNullOrWhiteSpace(project.Description)) { return(CommonResult.Failure("Project description is empty.")); } var existingProject = _projectsRepository.GetByName(project.Name); if (existingProject != null && !existingProject.IsDeleted && existingProject.Name == project.Name) { return(CommonResult.Failure("Project name already exists.")); } _projectsRepository.Add(project); return(CommonResult.Success()); }
public CommonResult <DrinkEditDto> Edit(int?id) { var drink = _db.Drinks.Where(s => s.Id == id).FirstOrDefault(); if (drink == null) { return(CommonResult <DrinkEditDto> .Failure <DrinkEditDto> ("No match id..")); } var editDrink = new DrinkEditDto { Name = drink.Name, Price = drink.Price, Id = drink.Id, Ratings = GetRatings(id) }; return(CommonResult <DrinkRating> .Success(editDrink)); }
public async Task <CommonResult <DrinkRatingDto> > SendRatingAsync(DrinkRatingDto rating) { if (rating.DrinkId == 0) { return(CommonResult <DrinkRatingDto> .Failure <DrinkRatingDto>("Drink id is 0")); } if (rating.Rating == 0) { return(CommonResult <DrinkRatingDto> .Failure <DrinkRatingDto>("Drink rating is 0 (not allowed)")); } bool RatingSuccess = await SaveChanges(rating); if (RatingSuccess == true) { return(CommonResult <DrinkRating> .Success(rating)); } return(CommonResult <DrinkRatingDto> .Failure <DrinkRatingDto> ("Something unexpected happend with db")); }
public async Task <CommonResult> Add(ApplicationUserDto user) { if (string.IsNullOrEmpty(user.Name)) { return(CommonResult.Failure("Cannot create user without name provided.")); } if (string.IsNullOrEmpty(user.LastName)) { return(CommonResult.Failure("Cannot create user without last name provided.")); } var person = await _personRepository.GetUser(user.Id); if (person != null && !person.IsDeleted && person.Name == user.Name && person.LastName == user.LastName) { return(CommonResult.Failure("User name and lastname already exists.")); } await _personRepository.AddUser(user); return(CommonResult.Success()); }