Exemplo n.º 1
0
        public ActionResult Edit(Guid id, [Bind("Id,Name,FullAddress,Latitude,Longitude,ImageUrl,PhoneNumber,Description")] PublicPlaces publicPlaces)
        {
            if (id != publicPlaces.Id)
            {
                return(NotFound());
            }

            try
            {
                var places        = storage.GetAll();
                var comparePlace  = storage.GetAll().Where(c => c.Id == id).FirstOrDefault();
                var placeToUpdate = places.Where(d => d.Id == id).FirstOrDefault();

                placeToUpdate.FullAddress = string.IsNullOrWhiteSpace(publicPlaces.FullAddress) ? placeToUpdate.FullAddress : publicPlaces.FullAddress;
                placeToUpdate.Name        = string.IsNullOrWhiteSpace(publicPlaces.Name) ? placeToUpdate.Name : publicPlaces.Name;
                placeToUpdate.Description = string.IsNullOrWhiteSpace(publicPlaces.Description) ? placeToUpdate.Description : publicPlaces.Description;
                placeToUpdate.PhoneNumber = string.IsNullOrWhiteSpace(publicPlaces.PhoneNumber) ? placeToUpdate.PhoneNumber : publicPlaces.PhoneNumber;
                placeToUpdate.ImageUrl    = string.IsNullOrWhiteSpace(publicPlaces.ImageUrl) ? placeToUpdate.ImageUrl : publicPlaces.ImageUrl;
                placeToUpdate.PostedBy    = PersistUser.userName;


                storage.Update(placeToUpdate, comparePlace);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
0
 public ActionResult Create([Bind("Id,Name,FullAddress,Latitude,Longitude,ImageUrl,PhoneNumber,Description")] PublicPlaces publicPlaces)
 {
     if (ModelState.IsValid)
     {
         publicPlaces.Id       = Guid.NewGuid();
         publicPlaces.PostedBy = PersistUser.userName;
         storage.Post(publicPlaces);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(publicPlaces));
 }
Exemplo n.º 3
0
 public ActionResult Create([Bind("Id,Name,FullAddress,Latitude,Longitude,Description")] PublicPlaces publicPlaces)
 {
     if (ModelState.IsValid)
     {
         publicPlaces.Id = Guid.NewGuid();
         storage.Post(publicPlaces);
         //_context.Add(publicPlaces);
         //await _context.SaveChangesAsync();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(publicPlaces));
 }
Exemplo n.º 4
0
 public PublicPlaces PostPlaces(PublicPlaces places) => storageBroker.Post(places);