示例#1
0
        public async Task <IActionResult> PetProducts(User user, PetRegistration petRegistracion)
        {
            var appUser = await _userManager.FindByNameAsync(User.Identity.Name);

            user.Email    = appUser.Email;
            user.UserName = appUser.UserName;
            var productList = _petContext.GetAllPet(petRegistracion).Where(e => e.UserName == user.UserName).OrderByDescending(e => e.PetRegistrationDateTime).ToList();

            return(View(productList));
        }
        public async Task <IActionResult> PetRegAsync(PetRegistrationViewModel petRegistrationViewModel)
        {
            if (ModelState.IsValid)
            {
                if (petRegistrationViewModel.PetPhoto != null)
                {
                    string folder = "Images/PetPhoto/";
                    folder += Guid.NewGuid().ToString() + "_" + petRegistrationViewModel.PetPhoto.FileName;

                    petRegistrationViewModel.PetPhotoUrl = "/" + folder;

                    string serverFolder = Path.Combine(_env.WebRootPath, folder);

                    await petRegistrationViewModel.PetPhoto.CopyToAsync(new FileStream(serverFolder, FileMode.Create));
                }
                var findUser = await _userManager.FindByNameAsync(User.Identity.Name);

                PetRegistration petRegistration = new PetRegistration()
                {
                    UserName = findUser.UserName,
                    PetRegistrationDateTime = DateTime.Now,
                    Age         = petRegistrationViewModel.Age,
                    City        = petRegistrationViewModel.City,
                    ContactName = petRegistrationViewModel.ContactName,
                    PetPhotoUrl = petRegistrationViewModel.PetPhotoUrl,
                    PhoneNumber = petRegistrationViewModel.PhoneNumber,
                    Sex         = petRegistrationViewModel.Sex,
                    Jishebi     = petRegistrationViewModel.Jishebi,
                    Price       = petRegistrationViewModel.Price,
                    Subject     = petRegistrationViewModel.Subject,
                    Title       = petRegistrationViewModel.Title
                };
                _petRegistrationRepo.RegisterPet(petRegistration);
                _petRegistrationRepo.SaveChange();
                return(RedirectToAction("PetDetails", "Pet", new { id = petRegistration.ID }));
            }
            return(View());
        }
        public IActionResult GetPets(string searchString, string searchJishebi, string searchSex, string searchCity, PetRegistration petRegistration)
        {
            var getAllPet = _petRegistrationRepo.GetAllPet(petRegistration);
            //საძიებო ველის ჯიშები (დასაწყისი)
            string JishebiReplaceString = null;

            if (searchJishebi != null && searchJishebi.Contains("-"))
            {
                JishebiReplaceString = searchJishebi.Replace("-", "_");
                if (JishebiReplaceString.Contains("(") || JishebiReplaceString.Contains(")"))
                {
                    JishebiReplaceString = JishebiReplaceString.Replace("(", "");
                    JishebiReplaceString = JishebiReplaceString.Replace(")", "");
                }
            }
            if (JishebiReplaceString == null && searchJishebi != null)
            {
                JishebiReplaceString = searchJishebi.Replace(" ", "_");
            }
            if (searchJishebi != null && JishebiReplaceString.Contains(" "))
            {
                JishebiReplaceString = JishebiReplaceString.Replace(" ", "_");
            }
            //საძიებო ველის ჯიშების ფილტრაცია (დასასრული)

            //საძიებო ველი(დასაწყისი)
            if (searchString == null && searchJishebi == null && searchSex == null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)));
            }
            if (searchString != null && searchJishebi == null && searchSex == null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString == null && searchJishebi != null && searchSex == null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))));
            }
            if (searchString == null && searchJishebi == null && searchSex != null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Sex.ToString() == searchSex)));
            }
            if (searchString == null && searchJishebi == null && searchSex == null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)));
            }
            if (searchString != null && searchJishebi != null && searchSex == null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString == null && searchJishebi == null && searchSex != null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => e.Sex.ToString() == searchSex)));
            }
            if (searchString != null && searchJishebi == null && searchSex != null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Sex.ToString() == searchSex)
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString == null && searchJishebi != null && searchSex == null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))));
            }
            if (searchString != null && searchJishebi == null && searchSex == null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString == null && searchJishebi != null && searchSex != null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Sex.ToString() == searchSex)));
            }
            if (searchString != null && searchJishebi != null && searchSex != null && searchCity == null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Sex.ToString() == searchSex)
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString == null && searchJishebi != null && searchSex != null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => searchJishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString != null && searchJishebi == null && searchSex != null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => e.Sex.ToString() == searchSex)
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString != null && searchJishebi != null && searchSex == null && searchCity != null)
            {
                return(View(getAllPet.OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.City.ToString() == searchCity)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            if (searchString != null && searchJishebi != null && searchSex != null && searchCity != null)
            {
                return(View(getAllPet.Where(e => e.City.ToString() == searchCity)
                            .OrderByDescending(e => e.PetRegistrationDateTime)
                            .Where(e => e.Sex.ToString() == searchSex)
                            .Where(e => e.Jishebi.ToString().StartsWith(JishebiReplaceString))
                            .Where(e => e.Title.Contains(searchString) || e.PhoneNumber == searchString)));
            }
            //საძიებო ველი(დასასრული)


            return(View());
        }
        public IActionResult GetPets(PetRegistration petRegistration)
        {
            var getAllPet = _petRegistrationRepo.GetAllPet(petRegistration).OrderByDescending(e => e.PetRegistrationDateTime);

            return(View(getAllPet));
        }
 public PetRegistration RemovePet(PetRegistration petRegistracion)
 {
     _context.GetPetRegistration.Remove(petRegistracion);
     return(petRegistracion);
 }
 public PetRegistration RegisterPet(PetRegistration petRegistracion)
 {
     _context.GetPetRegistration.Add(petRegistracion);
     return(petRegistracion);
 }
 public IEnumerable <PetRegistration> GetAllPet(PetRegistration petRegistracion)
 {
     return(_context.GetPetRegistration);
 }
示例#8
0
        public async Task <IActionResult> UserProfile(User user, VetRegistracion vetRegistracion, PetRegistration petRegistration, JobVacancy jobVacancy, Damakeba damakeba)
        {
            var appUser = await _userManager.FindByNameAsync(User.Identity.Name);

            user.Email    = appUser.Email;
            user.UserName = appUser.UserName;
            if (appUser.GenderValue == 0)
            {
                user.UserGender = 0;
            }
            else
            {
                user.UserGender = 1;
            }
            user.VetCount      = _vetContext.GetAllVet(vetRegistracion).Where(e => e.UserName == user.UserName).ToList().Count();
            user.PetCount      = _petContext.GetAllPet(petRegistration).Where(e => e.UserName == user.UserName).ToList().Count();
            user.VacancyCount  = _vacancyContext.GetAllJob(jobVacancy).Where(e => e.UserName == user.UserName).ToList().Count();
            user.DamakebaCount = _damakebaContext.GetAllProduct(damakeba).Where(e => e.UserName == user.UserName).ToList().Count();
            return(View(user));
        }