public ActionResult Add(int id, string FacilityType, string FacilityDescription,
            int? LeadContact, int? RoomHost, decimal? RoomCapacity, decimal? RoomSize,
            FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                var facility = new Facility();
                facility.PremiseID = id;
                facility.FacilityType = FacilityType;
                facility.FacilityDescription = FacilityDescription;
                facility.LeadContact = LeadContact;
                facility.RoomHost = RoomHost;
                if (facility.FacilityType == "Room")
                {
                    facility.RoomCapacity = RoomCapacity;
                    facility.RoomSize = RoomSize;
                    facility.RoomConnectivity = collection["RoomConnectivity"] == "1" ? 1 : 0;
                    facility.EquipmentAvailable = collection["EquipmentAvailable"] == "1" ? 1 : 0;
                    if (facility.EquipmentAvailable==1)
                        facility.EquipmentName = collection["EquipmentName"];
                    if (facility.RoomConnectivity == 1)
                    {
                        facility.ConnectivityType = collection["ConnectivityType"];
                        if (facility.ConnectivityType == "Wireless")
                            facility.WirelessAccessInfor = collection["WirelessAccessInfor"];
                    }
                    facility.RoomEquipmentNotes = collection["RoomEquipmentNotes"];
                }
                else if (facility.FacilityType == "Internet Access")
                {
                    facility.ConnectivityType = collection["ConnectivityType"];
                    if (facility.ConnectivityType == "Wireless")
                        facility.WirelessAccessInfor = collection["WirelessAccessInfor"];
                }
                facility.FacilityIsActive = 1;
                _db.Insert(facility);
                ViewBag.Alert = "true";
                ViewBag.Message = "Action success!";
                ViewBag.URL = "/Premise/Amend/" + id + "#tabs-5";

                return View("../Shared/Redirect");
            }
            catch
            {
                return View("../Shared/Error");
            }
        }
 //insert
 public void Insert(Facility facility)
 {
     _db.Facilities.InsertOnSubmit(facility);
     _db.SubmitChanges();
 }
 partial void DeleteFacility(Facility instance);
 partial void UpdateFacility(Facility instance);
 partial void InsertFacility(Facility instance);
		private void detach_Facilities1(Facility entity)
		{
			this.SendPropertyChanging();
			entity.Contact1 = null;
		}
		private void attach_Facilities(Facility entity)
		{
			this.SendPropertyChanging();
			entity.Contact = this;
		}
		private void detach_Facilities(Facility entity)
		{
			this.SendPropertyChanging();
			entity.Premise = null;
		}