예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,AddressId,IdentityUserId,BusinessTypeId")] PetBusiness petBusiness)
        {
            if (id != petBusiness.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repo.PetBusiness.Update(petBusiness);
                    await _repo.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetBusinessExists(petBusiness.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusinessType"] = new SelectList(_repo.BusinessType.GetAllBusinessTypes(), "Id", "TypeOfBusiness", petBusiness.BusinessType);
            return(View(petBusiness));
        }
예제 #2
0
        //public IActionResult EditUpdate(int id)
        //{
        //    FeedUpdate update = _repo.FeedUpdate.FindUpdateById(id);

        //    return View(update);

        //}

        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public IActionResult EditUpdate(int id, FeedUpdate post)
        //{
        //    FeedUpdate update = new FeedUpdate();
        //    update.Id = id;
        //    update.PubDate = post.PubDate;
        //    News
        //}


        // GET: PetBusinesses/Details/5
        public IActionResult Details(int?id)
        {
            string      userId      = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            PetBusiness petBusiness = _repo.PetBusiness.GetPetBusinessById(userId);

            return(View(petBusiness));
        }
예제 #3
0
        // GET: PetBusinesses/Create
        public IActionResult Create()
        {
            var         userId      = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            PetBusiness petBusiness = new PetBusiness();

            petBusiness.IdentityUserId = userId;

            ViewData["BusinessType"] = new SelectList(_repo.BusinessType.GetAllBusinessTypes(), "Id", "TypeOfBusiness", petBusiness.BusinessType);
            return(View(petBusiness));
        }
예제 #4
0
        public IActionResult CreateServiceOffered()
        {
            var            userId         = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            PetBusiness    petBusiness    = _repo.PetBusiness.GetPetBusinessById(userId);
            ServiceOffered serviceOffered = new ServiceOffered();

            serviceOffered.PetBusinessId = petBusiness.Id;
            //_repo.Service.GetAllServices();

            ViewData["Services"] = new SelectList(_repo.Service.GetAllServices(), "Id", "ServiceName");

            return(View(serviceOffered));
        }
예제 #5
0
        public IActionResult Create(PetBusiness petBusiness)
        {
            try
            {
                if (_repo.Address.GetByAddress(petBusiness.Address) == null)
                {
                    _repo.Address.CreateAddress(petBusiness.Address);
                    string url = _getCoordinates.GetAddressAsURL(petBusiness.Address);
                    petBusiness.Address.Lat = _getCoordinates.GetLat(url, petBusiness.Address).Result;
                    petBusiness.Address.Lng = _getCoordinates.GetLng(url, petBusiness.Address).Result;
                    _repo.Save();
                }
                else
                {
                    petBusiness.Address = _repo.Address.GetByAddress(petBusiness.Address);
                    string url = _getCoordinates.GetAddressAsURL(petBusiness.Address);
                    petBusiness.Address.Lat = _getCoordinates.GetLat(url, petBusiness.Address).Result;
                    petBusiness.Address.Lng = _getCoordinates.GetLng(url, petBusiness.Address).Result;
                    _repo.Save();
                }
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

                ObjectCalendar userCalender = new ObjectCalendar();
                userCalender.IdentityUserId = userId;
                _repo.ObjectCalendar.CreateCalendar(userCalender);
                _repo.Save();

                //TRY MOVING THIS AFTER DELETING and UPGRADING MIGRATION MY
                _repo.PetBusiness.CreatePetBusiness(petBusiness.Name, petBusiness.BusinessTypeId, petBusiness.Address.Id, userId);
                _repo.Save();

                return(RedirectToAction(nameof(Index)));
            }

            catch
            {
                ViewData["BusinessType"] = new SelectList(_repo.BusinessType.GetAllBusinessTypes(), "Id", "TypeOfBusiness", petBusiness.BusinessType);
                return(View(petBusiness));
            }
        }
        public IActionResult DisplayPetBusinessDetails(int id)
        {
            var userId     = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var petOwnerId = _repo.PetOwner.GetPetOwnerById(userId).Id;

            IEnumerable <ServiceOffered> servicesOffered = _repo.ServiceOffered.GetServicesOfferedIncludeAll(id);

            //NEED INCLUDE ALL reference in REPO
            PetBusiness petBusiness = _repo.PetBusiness.GetPetBusiness(id);
            Address     address     = _repo.Address.GetAddressById(petBusiness.AddressId);
            Follow      follow      = _repo.Follow.GetFollowByPetOwnerAndPetBusiness(id, petOwnerId);

            if (follow == null)
            {
                Follow newFollow = new Follow();
                newFollow.PetOwnerId    = petOwnerId;
                newFollow.PetBusinessId = id;
                newFollow.IsFollowing   = false;
                _repo.Follow.CreateFollow(newFollow);
                _repo.Save();

                follow = newFollow;
            }

            ViewModelPetBusiness petBusinessViewing = new ViewModelPetBusiness();

            petBusinessViewing.PetBusiness    = petBusiness;
            petBusinessViewing.PetBusinessId  = id;
            petBusinessViewing.PetOwnerId     = petOwnerId;
            petBusinessViewing.Name           = petBusiness.Name;
            petBusinessViewing.BusinessTypeId = petBusiness.BusinessTypeId;
            petBusinessViewing.Address        = address;
            petBusinessViewing.IsFollowing    = follow.IsFollowing;
            //petBusinessViewing.Address.Lat = address.Lat;
            //petBusinessViewing.Address.Lng = address.Lng;
            petBusinessViewing.ServicesOffered = servicesOffered.ToList();

            return(View(petBusinessViewing));
        }
예제 #7
0
        public JsonResult <List <Pet> > GetPetByCliente(int cliente_id)
        {
            PetBusiness pet_busines = new PetBusiness();

            return(Json(pet_busines.GetPetByCliente(cliente_id)));
        }
예제 #8
0
        public JsonResult <Pet> Get(int pet_id)
        {
            PetBusiness pet_busines = new PetBusiness();

            return(Json(pet_busines.GetPet(pet_id)));
        }
예제 #9
0
        public JsonResult <List <Pet> > GetAll()
        {
            PetBusiness pet_busines = new PetBusiness();

            return(Json(pet_busines.GetAllPets()));
        }
예제 #10
0
        public JsonResult <bool> Cadastrar(ViewModelCadastroPet vm_cadastro_pet)
        {
            PetBusiness pet_busines = new PetBusiness();

            return(Json(pet_busines.CadastrarPet(vm_cadastro_pet)));
        }