public ActionResult ProfileInfo(int UserID) { var data = db.Get_Profile(UserID).FirstOrDefault(); ShowProfile obj = new ShowProfile(); if (data != null) { obj.UserID = data.UserID; if (data.DateOfBirth == null) { obj.DateOfBirth = DateTime.Now; } else { obj.DateOfBirth = data.DateOfBirth.Value; } var UserProfile = db.UserRegistrations.Where(x => x.UserID == data.UserID).FirstOrDefault(); obj.Work = data.IndustryName; obj.Gender = data.GenderName; obj.MritalStatus = data.Status; obj.RAddress = data.RAddress; obj.FirstName = UserProfile.FirstName; obj.LastName = UserProfile.LastName; obj.MiddleName = UserProfile.MiddleName; obj.City = data.CityName; obj.State = data.StateName; obj.Email = data.Email; obj.Mobile = data.Mobile; obj.BloodGroup = data.BloodG; obj.MyAppID = data.MyAppID; obj.ImagePath = data.ImagePath; } else { int uid = Convert.ToInt32(Session["UserID"].ToString()); obj.UserID = Convert.ToInt32(Session["UserID"].ToString()); obj.DateOfBirth = DateTime.Now; obj.Work = ""; obj.Gender = ""; obj.MritalStatus = ""; obj.RAddress = ""; var UserProfile = db.UserRegistrations.Where(x => x.UserID == data.UserID).FirstOrDefault(); obj.FirstName = UserProfile.FirstName; obj.LastName = UserProfile.LastName; obj.MiddleName = UserProfile.MiddleName; obj.City = db.Cities.Where(x => x.CityID == UserProfile.CityID).FirstOrDefault().CityName; obj.Email = db.UserRegistrations.Where(x => x.UserID == uid).FirstOrDefault().Email; obj.Mobile = db.UserRegistrations.Where(x => x.UserID == uid).FirstOrDefault().Mobile; obj.BloodGroup = "Not Available"; obj.ImagePath = "/Images/Photo.jpg"; } return(PartialView("_ucProfile", obj)); }