public ActionResult SaveMatrimonial(Matrimonial model, HttpPostedFileBase fPic) { ResponseMsg response = new ResponseMsg(); try { int matrimonialId = clsBusinessLogic.SaveMatrimonial(model, ((BhagwatiSamaj.Models.User)Session["CurrentUser"]).Id.ToString()); if (matrimonialId > 0) { if (fPic != null) { fPic.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["MatrimonialPhotoPath"]) + matrimonialId + System.IO.Path.GetExtension(fPic.FileName)); clsBusinessLogic.UpdateMatrimonialPhoto(matrimonialId, matrimonialId + System.IO.Path.GetExtension(fPic.FileName)); } } else { response.IsSuccess = false; response.ResponseValue = "Error while saving candidate, Please try after sometime."; return(Json(response)); } response.IsSuccess = true; response.ResponseValue = ""; } catch (Exception ex) { response.IsSuccess = false; response.ResponseValue = ex.Message; } return(Json(response)); }
public IHttpActionResult UploadPhoto(dynamic json) { dynamic model = JsonConvert.DeserializeObject <ExpandoObject>(json.ToString()); int memberId = Convert.ToInt32(model.memberId); int photoNumber = Convert.ToInt32(model.photoNumber); if (!CanEditMember(memberId)) { return(BadRequest("You do not have permission to edit this member")); } if (string.IsNullOrWhiteSpace(model.image)) { return(BadRequest("No image content provided")); } if (photoNumber < 1 || photoNumber > 3) { return(BadRequest("Invalid photo number")); } byte[] imageBytes = Convert.FromBase64String(model.image.Replace("data:image/jpeg;base64,", "")); using (MemoryStream stream = new MemoryStream(imageBytes)) { Image img = Image.FromStream(stream); string filePath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format(@"~/Images/Matrimonials/{0}_{1}.jpg", memberId, photoNumber)); img.Save(filePath); } using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); if (mat != null) { mat.ModifiedBy = LoggedInMemberId; mat.ModifiedOn = DateTime.Now; context.SaveChanges(); } } return(Ok()); }
public IHttpActionResult Delete(int memberId) { using (bkContext context = new bkContext()) { if (!CanEditMember(memberId)) { return(BadRequest("You do not have permission to delete this record")); } Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); if (mat == null) { return(BadRequest("Matrimony profile cannot be loaded")); } context.Matrimonials.Remove(mat); context.SaveChanges(); } return(Ok()); }
public IHttpActionResult Get(int memberId) { using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); Member member = context.Members.FirstOrDefault(x => x.MemberID == memberId); if (mat == null) { return(BadRequest("Matrimony profile cannot be loaded")); } MatrimonyViewModel model = new MatrimonyViewModel(); model.Alcohol = mat.Alcohol; model.BirthTime = mat.BirthTime; model.BodyTypeId = mat.BodyTypeID; model.ComplexionTypeId = mat.ComplexionTypeID; model.Disability = mat.Disability; model.Height = mat.Height; model.Language = mat.Language; model.Mangal = mat.Mangal; model.MaritalStatusId = mat.MaritalStatusID; model.MaternalNukhId = mat.MaternalNukhID; model.MemberId = mat.MemberID; model.MonthlyIncome = mat.MonthlyIncome; model.OwnHome = mat.OwnHome; model.ProfileText = mat.ProfileText; model.Smoke = mat.Smoke; model.Tobacco = mat.Tobacco; model.Vegetarian = mat.Vegetarian; model.Weight = mat.Weight; model.Photo1Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 1, mat.ModifiedOn); model.Photo2Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 2, mat.ModifiedOn); model.Photo3Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 3, mat.ModifiedOn); return(Ok(model)); } }
public IHttpActionResult DeletePhoto(int photoNumber, int memberId) { if (!CanEditMember(memberId)) { return(BadRequest("You do not have permission to edit this member")); } if (photoNumber < 1 || photoNumber > 3) { return(BadRequest("Invalid photo number")); } string filePath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format(@"~/Images/Matrimonials/{0}_{1}.jpg", memberId, photoNumber)); if (File.Exists(filePath)) { File.Delete(filePath); } string response = string.Empty; using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); if (mat != null) { mat.ModifiedBy = LoggedInMemberId; mat.ModifiedOn = DateTime.Now; context.SaveChanges(); } response = MemberWrapper.MatrimonyPhoto(memberId, mat.Member.Gender, photoNumber, mat.ModifiedOn); } return(Ok(response)); }
public ActionResult AddMatrimonial(string Id) { ViewBag.CountryList = clsBusinessLogic.GetCountryList(); ViewBag.StateList = new List <State>(); ViewBag.CityList = new List <City>(); if (Id == "0") { if (Session["CurrentUser"] != null) { var model = new Matrimonial(); model.IsActive = true; return(View(model)); } else { Session["LastPage"] = "AddMatrimonial"; return(RedirectToAction("SignIn", "Account")); } } else { return(View(clsBusinessLogic.GetMatrimonialById(Id))); } }
public IHttpActionResult GetMatrimony(int memberId) { using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); if (mat == null) { return(BadRequest("Matrimony profile cannot be loaded")); } Member member = context.Members.FirstOrDefault(x => x.MemberID == memberId); if (member == null) { return(BadRequest("Matrimony profile cannot be loaded")); } MatrimonyViewOnlyModel model = new MatrimonyViewOnlyModel(); model.MatrimonyModel.Alcohol = mat.Alcohol; model.MatrimonyModel.BirthTime = mat.BirthTime; model.MatrimonyModel.BodyTypeId = mat.BodyTypeID; model.MatrimonyModel.ComplexionTypeId = mat.ComplexionTypeID; model.MatrimonyModel.Disability = mat.Disability; model.MatrimonyModel.Height = mat.Height; model.MatrimonyModel.Language = mat.Language; model.MatrimonyModel.Mangal = mat.Mangal; model.MatrimonyModel.MaritalStatusId = mat.MaritalStatusID; model.MatrimonyModel.MaternalNukhId = mat.MaternalNukhID; model.MatrimonyModel.MemberId = mat.MemberID; model.MatrimonyModel.MonthlyIncome = mat.MonthlyIncome; model.MatrimonyModel.OwnHome = mat.OwnHome; model.MatrimonyModel.ProfileText = mat.ProfileText; model.MatrimonyModel.Smoke = mat.Smoke; model.MatrimonyModel.Tobacco = mat.Tobacco; model.MatrimonyModel.Vegetarian = mat.Vegetarian; model.MatrimonyModel.Weight = mat.Weight; model.MatrimonyModel.Photo1Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 1, mat.ModifiedOn); model.MatrimonyModel.Photo2Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 2, mat.ModifiedOn); model.MatrimonyModel.Photo3Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 3, mat.ModifiedOn); model.MemberModel.MemberID = member.MemberID; model.MemberModel.FirstName = member.FirstName; model.MemberModel.LastName = member.LastName; model.MemberModel.NickName = member.NickName; model.MemberModel.Email = member.EmailAddress; model.MemberModel.PhoneNumber = member.Phone; model.MemberModel.Gender = member.Gender; model.MemberModel.DOB = member.DOB; model.MemberModel.BirthPlace = member.BirthPlace; model.MemberModel.Alive = member.Alive; model.MemberModel.DOD = member.DOD; model.MemberModel.DeathPlace = member.DeathPlace; model.MemberModel.EducationLevel = member.EducationLevel; model.MemberModel.EducationField = member.EducationField; model.MemberModel.OccupationId = member.OccupationID; model.MemberModel.CompanyName = member.CompanyName; model.MemberModel.JobTitle = member.JobTitle; model.MemberModel.InstagramHandle = member.InstagramHandle; model.MemberModel.FacebookHandle = member.FacebookHandle; model.MemberModel.TwitterHandle = member.TwitterHandle; model.MemberModel.MaritalStatusId = member.MaritalStatusID; model.MemberModel.PhotoUrl = MemberWrapper.ProfilePhoto(member.MemberID, member.Gender, member.ModifiedOn); model.MemberModel.FamilyId = member.FamilyMemberAssociations.Where(x => x.DefaultFamily).Select(x => x.FamilyId).FirstOrDefault(); model.MemberModel.ModifiedOn = mat.ModifiedOn.HasValue ? mat.ModifiedOn : mat.CreatedOn; if (member.ModifiedOn > model.MemberModel.ModifiedOn) { model.MemberModel.ModifiedOn = member.ModifiedOn; } GetMaternalFamily_Result mResult = context.GetMaternalFamily(member.MemberID).FirstOrDefault(); if (mResult != null) { model.MemberModel.MaternalFamilyId = mResult.MaternalFamilyID; model.MemberModel.MaternalFamilyName = string.Format("{0}, {1}", mResult.MaternalFamilyName, mResult.MaternalFamilyAddress); } return(Ok(model)); } }
public IHttpActionResult Save(MatrimonyViewModel model) { using (bkContext context = new bkContext()) { if (!CanEditMember(model.MemberId)) { return(BadRequest("You do not have permission to update this record")); } Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == model.MemberId); Member member = context.Members.FirstOrDefault(x => x.MemberID == model.MemberId); if (member == null) { return(BadRequest("Member record cannot be loaded. Please try again later")); } if (!member.Alive) { return(BadRequest("You cannot create a matrimony profile unless a member is alive")); } if (member.MaritalStatusID == 2) { return(BadRequest("You cannot create a matrimony profile because person's marital status is set to Married")); } if (!member.DOB.HasValue) { return(BadRequest("You cannot create a matrimony profile because person's Date Of Birth is missing")); } if (member.Gender && MemberWrapper.Age(member.DOB.Value) < 21) { return(BadRequest("You cannot create a matrimony profile because person's age is less than 21")); } if (!member.Gender && MemberWrapper.Age(member.DOB.Value) < 18) { return(BadRequest("You cannot create a matrimony profile because person's age is less than 18")); } if (mat != null) { mat.ModifiedBy = LoggedInMemberId; mat.ModifiedOn = DateTime.Now; } else { mat = new Matrimonial(); mat.CreatedBy = LoggedInMemberId; mat.CreatedOn = DateTime.Now; mat.MemberID = model.MemberId; context.Matrimonials.Add(mat); } mat.Alcohol = model.Alcohol; mat.BirthTime = model.BirthTime; mat.BodyTypeID = model.BodyTypeId; mat.ComplexionTypeID = model.ComplexionTypeId; mat.Disability = model.Disability; mat.Height = model.Height; mat.Language = model.Language; mat.Mangal = model.Mangal; mat.MaritalStatusID = model.MaritalStatusId; mat.MaternalNukhID = model.MaternalNukhId; mat.MonthlyIncome = model.MonthlyIncome; mat.OwnHome = model.OwnHome; mat.ProfileText = model.ProfileText; mat.Smoke = model.Smoke; mat.Tobacco = model.Tobacco; mat.Vegetarian = model.Vegetarian; mat.Weight = model.Weight; context.SaveChanges(); } return(Ok()); }