Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("UserID,TransactionRef,PaymentStatus,Amount,DateCreated,PaymentType,ActivityID,IsAttended,Id")] Booking booking)
        {
            var currentUser = HttpContext.Session.Get <User>(Constants.SessionKeyUser);

            if (currentUser == null || id != booking.Id)
            {
                return(NotFound());
            }

            if (currentUser.IsViewOnly)
            {
                return(Forbid());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(booking);
                    await _context.SaveChangesAsync();

                    // send email notification
                    if (booking.PaymentType == PaymentType.Cash && booking.PaymentStatus == PaymentStatus.Successful)
                    {
                        await _emailHelper.SendCashBookingSuccessfulEmailAsync(id);
                    }
                    else if (booking.PaymentStatus == PaymentStatus.Failed)
                    {
                        await _emailHelper.SendPaymentFailedEmailAsync(id);
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookingExists(booking.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ActivityID"] = new SelectList(_context.Activities, "Id", "Title", booking.ActivityID);
            return(View(booking));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Title,Description,PictureUrl,Capacity,StartDate,EndDate,Amount,HouseKeepingInfo,IsActive,LocationID,ActivityTypeID,Id")] Activity activity)
        {
            var currentUser = HttpContext.Session.Get <User>(Constants.SessionKeyUser);

            if (currentUser == null || id != activity.Id)
            {
                return(NotFound());
            }

            if (currentUser.IsViewOnly)
            {
                return(Forbid());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(activity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ActivityExists(activity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ActivityTypeID"] = new SelectList(_context.ActivityTypes, "Id", "Name", activity.ActivityTypeID);
            ViewData["LocationID"]     = new SelectList(_context.Locations, "Id", "Name", activity.LocationID);
            return(View(activity));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("AspId,FirstName,MiddleName,LastName,Email,PhoneNumber,AgeRange,IsViewOnly,MemberType,Id")] User user)
        {
            var currentUser = HttpContext.Session.Get <User>(Constants.SessionKeyUser);

            if (currentUser == null || id != user.Id)
            {
                return(NotFound());
            }

            if (currentUser.IsViewOnly)
            {
                return(Forbid());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Value,Id")] Setting setting)
        {
            var currentUser = HttpContext.Session.Get <User>(Constants.SessionKeyUser);

            if (currentUser == null || id != setting.Id)
            {
                return(NotFound());
            }

            if (currentUser.IsViewOnly)
            {
                return(Forbid());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(setting);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SettingExists(setting.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(setting));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Address,PictureUrl,ContactPhone,MapUrl,Coordinate,Id")] Location location)
        {
            var currentUser = HttpContext.Session.Get <User>(Constants.SessionKeyUser);

            if (currentUser == null || id != location.Id)
            {
                return(NotFound());
            }

            if (currentUser.IsViewOnly)
            {
                return(Forbid());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(location);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationExists(location.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }