<commit_before>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using CVGS.Models;

namespace CVGS.Controllers
{
    public class AddressController : Controller
    {
        private CVGSEntities db = new CVGSEntities();

        // GET: Address
        public ActionResult Index()
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            var aDDRESSes = db.ADDRESSes.Include(a => a.MEMBER).Include(a => a.PROVSTATE).Include(a => a.ADDRESSTYPE).ToList().FindAll(x => x.MemberId.Equals(memberId));
            return View(aDDRESSes.ToList());
        }

        // GET: Address/Details/5
        public ActionResult Details(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Find(id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            return View(aDDRESS);
        }

        // GET: Address/Create
        public ActionResult Create()
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode");
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName");
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode");
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName");
            return View();
        }

        // POST: Address/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "AddressId,MemberId,StreetAddress,StreetAddress2,City,PostCode,ProvStateId,AddressTypeId")] ADDRESS aDDRESS)
        {
            if (ModelState.IsValid)
            {
                db.ADDRESSes.Add(aDDRESS);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // GET: Address/Edit/5
        public ActionResult Edit(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Find(id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // POST: Address/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "AddressId,MemberId,StreetAddress,StreetAddress2,City,PostCode,ProvStateId,AddressTypeId")] ADDRESS aDDRESS)
        {
            if (ModelState.IsValid)
            {
                db.Entry(aDDRESS).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // GET: Address/Delete/5
        public ActionResult Delete(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Find(id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            return View(aDDRESS);
        }

        // POST: Address/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            ADDRESS aDDRESS = db.ADDRESSes.Find(id);
            db.ADDRESSes.Remove(aDDRESS);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
<commit_msg>Add where not deleted to address controller<commit_after>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using CVGS.Models;

namespace CVGS.Controllers
{
    public class AddressController : Controller
    {
        private CVGSEntities db = new CVGSEntities();

        // GET: Address
        public ActionResult Index()
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            var aDDRESSes = db.ADDRESSes.Include(a => a.MEMBER).Include(a => a.PROVSTATE).Include(a => a.ADDRESSTYPE).Where(a=>!(bool)a.Deleted).ToList().FindAll(x => x.MemberId.Equals(memberId));
            return View(aDDRESSes.ToList());
        }

        // GET: Address/Details/5
        public ActionResult Details(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Where(a => !(bool)a.Deleted).ToList().Find(a => a.AddressId == id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            return View(aDDRESS);
        }

        // GET: Address/Create
        public ActionResult Create()
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode");
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName");
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode");
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName");
            return View();
        }

        // POST: Address/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "AddressId,MemberId,StreetAddress,StreetAddress2,City,PostCode,ProvStateId,AddressTypeId")] ADDRESS aDDRESS)
        {
            if (ModelState.IsValid)
            {
                db.ADDRESSes.Add(aDDRESS);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // GET: Address/Edit/5
        public ActionResult Edit(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Where(a => !(bool)a.Deleted).ToList().Find(a => a.AddressId == id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // POST: Address/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "AddressId,MemberId,StreetAddress,StreetAddress2,City,PostCode,ProvStateId,AddressTypeId")] ADDRESS aDDRESS)
        {
            if (ModelState.IsValid)
            {
                db.Entry(aDDRESS).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            //ViewBag.CountryId = new SelectList(db.COUNTRies, "CountryId", "CountryCode", aDDRESS.CountryId);
            ViewBag.MemberId = new SelectList(db.MEMBERs, "MemberId", "FName", aDDRESS.MemberId);
            ViewBag.ProvStateId = new SelectList(db.PROVSTATEs, "ProvStateId", "ProvStateCode", aDDRESS.ProvStateId);
            ViewBag.AddressTypeId = new SelectList(db.ADDRESSTYPEs, "AddressTypeId", "AddressTypeName", aDDRESS.AddressTypeId);
            return View(aDDRESS);
        }

        // GET: Address/Delete/5
        public ActionResult Delete(int? id)
        {
            var memberId = this.Session["MemberId"];
            // Redirect unauthenticated members
            if (memberId == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ADDRESS aDDRESS = db.ADDRESSes.Where(a => !(bool)a.Deleted).ToList().Find(a => a.AddressId == id);
            if (aDDRESS == null)
            {
                return HttpNotFound();
            }
            return View(aDDRESS);
        }

        // POST: Address/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            ADDRESS aDDRESS = db.ADDRESSes.Find(id);
            db.ADDRESSes.Remove(aDDRESS);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

{'fraction_non_alphanumeric': 0.10959497509205111, 'fraction_numerical': 0.0027434842249657062, 'mean_word_length': 1.932881643023502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3936443', 'n_tokens_mistral': 3883, 'n_tokens_neox': 3841, 'n_words': 755}