Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Year,AnnualFee,EarlyDiscountedFee,EarlyDiscountEndDate,RenewDeadlineDate,TaskExemptionFee,SecondBoatFee,ThirdBoatFee,ForthAndSubsequentBoatFee,NonSailFee,NewMember25DiscountDate,NewMember50DiscountDate,NewMember75DiscountDate")] AnnualFeeStructure annualFeeStructure)
        {
            if (id != annualFeeStructure.Year)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (id != DateTime.Now.Year)
                    {
                        TempData["message"] = "A prior year's record can not be changed.";
                        return(RedirectToAction("index"));
                    }
                    else
                    {
                        _context.Update(annualFeeStructure);
                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnnualFeeStructureExists(annualFeeStructure.Year))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(annualFeeStructure));
        }
        public async Task <IActionResult> Edit(int id, [Bind("MemberId,FullName,FirstName,LastName,SpouseFirstName,SpouseLastName,Street,City,ProvinceCode,PostalCode,HomePhone,Email,YearJoined,Comment,TaskExempt,UseCanadaPost")] Member member)
        {
            if (id != member.MemberId)
            {
                return(NotFound());
            }

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

                    TempData["message"] = "Member information has been updated successfully";
                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MemberExists(member.MemberId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.GetBaseException().Message);
                    TempData["message"] = ex.GetBaseException().Message;
                }
            }
            ViewData["ProvinceCode"] = new SelectList(_context.Province, "ProvinceCode", "ProvinceCode", member.ProvinceCode);
            return(View(member));
        }
        public async Task <IActionResult> Edit(string id, [Bind("MembershipTypeName,Description,RatioToFull")] MembershipType membershipType)
        {
            try
            {
                if (id != membershipType.MembershipTypeName)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(membershipType);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!MembershipTypeExists(membershipType.MembershipTypeName))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
                return(View(membershipType));
            }
            catch (Exception ex)
            {
                TempData["error"] = ex.GetBaseException().Message;
                return(RedirectToAction("Index", "BPMembershipType"));
            }
        }
        public async Task <IActionResult> Edit(string id, [Bind("ProvinceCode,Name,CountryCode,TaxCode,TaxRate,Capital,IncludesFerderalTax")] Province province)
        {
            if (id != province.ProvinceCode)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Province thisProvince = province;

                    thisProvince.ProvinceCode = province.ProvinceCode;
                    thisProvince.Name         = province.Name;

                    _context.Update(thisProvince);
                    TempData["message"] = "Province edited successfully..";
                    await _context.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    if (!ProvinceExists(province.ProvinceCode))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        TempData["message"] = "Error editing province: " + ex.GetBaseException().Message;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryCode"] = new SelectList(_context.Country, "CountryCode", "CountryCode", province.CountryCode);
            return(View(province));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("BoatId,MemberId,BoatClass,HullColour,SailNumber,HullLength,BoatTypeId,ParkingCode")] Boat boat)
        {
            if (id != boat.BoatId)
            {
                return(NotFound());
            }

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

                    TempData["message"] = "boat edited: " + boat.BoatId;
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", $"error editing boat: {ex.GetBaseException().Message}");
            }

            ViewData["BoatTypeId"] = new SelectList(_context.BoatType, "BoatTypeId", "Name", boat.BoatTypeId);
            ViewData["MemberId"]   = new SelectList(_context.Member, "MemberId", "FirstName", boat.MemberId);
            if (boat.ParkingCode == null || boat.ParkingCode == "")
            {
                ViewData["ParkingCode"] = new SelectList(_context.Parking.Where(a => a.ActualBoatId == null || a.ParkingCode == "").OrderBy(a => a.ParkingCode), "ParkingCode", "ParkingCode", boat.ParkingCode);
            }
            else
            {
                ViewData["ParkingCode"] = new SelectList(_context.Parking.Where(a => a.BoatTypeId == boat.BoatTypeId).OrderBy(a => a.ParkingCode), "ParkingCode", "ParkingCode", boat.ParkingCode);
            }

            return(View(boat));
        }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("MembershipId,MemberId,Year,MembershipTypeName,Fee,Comments,Paid")] Membership membership)
        {
            if (id != membership.MembershipId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(membership);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MembershipExists(membership.MembershipId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            if (membership.Year < DateTime.Today.Year)
            {
                TempData["message"] = "Cannot edit previous year memberships";
                return(RedirectToAction("Index"));
            }
            ViewData["MemberId"]           = new SelectList(_context.Member, "MemberId", "FirstName", membership.MemberId);
            ViewData["MembershipTypeName"] = new SelectList(_context.MembershipType, "MembershipTypeName", "MembershipTypeName", membership.MembershipTypeName);
            return(View(membership));
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("MemberId,FullName,FirstName,LastName,SpouseFirstName,SpouseLastName,Street,City,ProvinceCode,PostalCode,HomePhone,Email,YearJoined,Comment,TaskExempt,UseCanadaPost")] Member member)
        {
            if (id != member.MemberId)
            {
                return(NotFound());
            }

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

                    TempData["message"] = $"Record updated for: {member.FullName}";
                    return(RedirectToAction("Index"));
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    if (!MemberExists(member.MemberId))
                    {
                        ModelState.AddModelError("", $"Member under the name {member.FullName} is not on file");
                    }
                    else
                    {
                        ModelState.AddModelError("", $"Concurrency exception: {ex.GetBaseException().Message} ");
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", $"update error: {ex.GetBaseException().Message}");
                }
            }
            ViewData["ProvinceCode"] = new SelectList(_context.Province.OrderBy(pc => pc.Name), "ProvinceCode", "Name", member.ProvinceCode);
            return(View(member));
        }
        public async Task <IActionResult> Edit(string id, [Bind("ParkingCode,BoatTypeId,ActualBoatId")] Parking parking)
        {
            if (id != parking.ParkingCode)
            {
                return(NotFound());
            }
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Update(parking);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "parking space edited: " + parking.ParkingCode;
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", $"error editing boat: {ex.GetBaseException().Message}");
            }
            ViewData["BoatTypeId"] = new SelectList(_context.BoatType.OrderBy(a => a.Name), "BoatTypeId", "Name", parking.BoatTypeId);
            return(View(parking));
        }
Пример #9
0
        public async Task <IActionResult> Edit(int id, [Bind("MemberId,FullName,FirstName,LastName,SpouseFirstName,SpouseLastName,Street,City,ProvinceCode,PostalCode,HomePhone,Email,YearJoined,Comment,TaskExempt,UseCanadaPost")] Member member)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Update(member);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "Member " + member.FullName + " was edited";
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Eerror encountered while editing: ", ex.GetBaseException().Message);
            }



            ViewData["Title"]        = "Edit  " + member.FullName;
            ViewData["ProvinceCode"] = new SelectList(_context.Province.OrderBy(a => a.Name), "ProvinceCode", "Name");
            return(View(member));
        }