Beispiel #1
0
		// Generate a new ID for AGENT_LINK_CLIENT data when insert a new AGENT_LINK_CLIENT data into database.
		private int generateAgentLinkClientID()
		{
			using (var db = new DB_9DB5CF_skylimitcapitalEntities())
			{
				var last = db.AGENT_LINK_CLIENT.OrderByDescending(r => r.Id).FirstOrDefault();
				if (last == null)
				{
					return 1;
				}
				else
				{
					return last.Id + 1;
				}
			}
		}
Beispiel #2
0
		// Generate a new ID for real_photo data when insert a new real_photo data into database.
		private int generatePhotoID()
		{
			using (var db = new DB_9DB5CF_skylimitcapitalEntities())
			{
				var last = db.Real_Photos.OrderByDescending(r => r.ID).FirstOrDefault();
				if (last == null)
				{
					return 1;
				}
				else
				{
					return last.ID + 1;
				}
			}
		}
Beispiel #3
0
		// Generate a new ID for Contract data when insert a new Contract data into database.
		private int generateContractID()
		{
			using (var db = new DB_9DB5CF_skylimitcapitalEntities())
			{
				var last = db.Contracts.OrderByDescending(r => r.id).FirstOrDefault();
				if (last == null)
				{
					return 1;
				}
				else
				{
					return last.id + 1;
				}
			}
		}
Beispiel #4
0
		public ActionResult CreateRealEstate(Real real, string StateType, string CountyName, HttpPostedFileBase[] images)
		{
			var firm = (Firm)Session["Firm"];
			if (firm == null)
			{
				return RedirectToAction("Index");
			}
			using (var db = new DB_9DB5CF_skylimitcapitalEntities())
			{
				var state = db.USAStates.Where(s => s.ShortName == StateType).FirstOrDefault();
				real.State = state.StateNameEng;
				var county = db.Counties.Where(c => c.Name.Contains(CountyName) && c.State == state.StateNameEng).FirstOrDefault();
				real.County = county.id;
				real.Image = "default.jpg";//delete
				real.ID = generateRealID();
				db.Reals.Add(real);
				db.SaveChanges();

				var firm_real = new Firm_has_Real
				{
					id = generateFirmHasRealID(),
					FirmID = firm.Id,
					RealID = real.ID
				};
				db.Firm_has_Real.Add(firm_real);
				db.SaveChanges();

				if (images != null)
				{
					foreach (var image in images)
					{
						string picName = System.IO.Path.GetFileName(image.FileName);
						picName = firm.Name + "_" + DateTime.Now.ToFileTimeUtc().ToString() + "_" + picName;

						var photo = new Real_Photos
						{
							ID = generatePhotoID(),
							Name = picName,
							RealId = real.ID
						};
						//real.Image = picName;
						string path = System.IO.Path.Combine(Server.MapPath("/Images/RealEstatePictures"), picName);
						// file is uploaded
						image.SaveAs(path);
						db.Real_Photos.Add(photo);
						db.SaveChanges();
					}
				}
				ViewBag.PageIndex = SidebarIndex.UPLOAD_PROPERTY;
				return RedirectToAction("upLoadedRealsListPage");
			}
		}