public ActionResult EditMatrimony(int id)
        {
            var matrimonyRecord = _sacramentRepository.GetMatrimony(id);
            var matrimony       = new MatrimonyViewModel
            {
                DateOfMarriage      = matrimonyRecord.DateOfMarriage,
                PlaceOfMarriage     = matrimonyRecord.PlaceOfMarriage,
                BrideFullName       = matrimonyRecord.BrideFullName,
                GroomFullName       = matrimonyRecord.GroomFullName,
                BrideAddress        = matrimonyRecord.BrideAddress,
                GroomAddress        = matrimonyRecord.GroomAddress,
                BrideAge            = (int)matrimonyRecord.BrideAge,
                GroomAge            = (int)matrimonyRecord.GroomAge,
                BrideBaptismPlace   = matrimonyRecord.BrideBaptismPlace,
                BrideBaptismDate    = matrimonyRecord.BrideBaptismDate,
                BrideBaptismNo      = matrimonyRecord.BrideBaptismNo,
                GroomBaptismPlace   = matrimonyRecord.GroomBaptismPlace,
                GroomBaptismDate    = matrimonyRecord.GroomBaptismDate,
                GroomBaptismNo      = matrimonyRecord.GroomBaptismNo,
                AssistingPriest     = matrimonyRecord.AssistingPriest,
                BannDetails         = matrimonyRecord.BannDetails,
                BrideParentName     = matrimonyRecord.BrideParentName,
                BrideParentHomeTown = matrimonyRecord.BrideParentHomeTown,
                GroomParentName     = matrimonyRecord.GroomParentName,
                GroomParentHomeTown = matrimonyRecord.GroomParentHomeTown,
                Witness1            = matrimonyRecord.Witness1,
                Witness2            = matrimonyRecord.Witness2,
                Remark = matrimonyRecord.Remark
            };

            return(View(matrimony));
        }
 public ActionResult EditMatrimony(MatrimonyViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         var matrimony = new Matrimony
         {
             Id                  = model.Id,
             DateOfMarriage      = model.DateOfMarriage,
             PlaceOfMarriage     = model.PlaceOfMarriage,
             BrideFullName       = model.BrideFullName,
             GroomFullName       = model.GroomFullName,
             BrideAddress        = model.BrideAddress,
             GroomAddress        = model.GroomAddress,
             BrideAge            = model.BrideAge,
             GroomAge            = model.GroomAge,
             BrideBaptismPlace   = model.BrideBaptismPlace,
             BrideBaptismDate    = model.BrideBaptismDate,
             BrideBaptismNo      = model.BrideBaptismNo,
             GroomBaptismPlace   = model.GroomBaptismPlace,
             GroomBaptismDate    = model.GroomBaptismDate,
             GroomBaptismNo      = model.GroomBaptismNo,
             AssistingPriest     = model.AssistingPriest,
             BannDetails         = model.BannDetails,
             BrideParentName     = model.BrideParentName,
             BrideParentHomeTown = model.BrideParentHomeTown,
             GroomParentName     = model.GroomParentName,
             GroomParentHomeTown = model.GroomParentHomeTown,
             Witness1            = model.Witness1,
             Witness2            = model.Witness2,
             Remark              = model.Remark,
             Deleted             = 0,
             UpdateDate          = DateTime.Now
         };
         if (_sacramentRepository.UpdateMatrimony(matrimony))
         {
             var returnData = new ReturnData
             {
                 HasValue = true,
                 Message  = "Marriage record was successfully updated"
             };
             TempData["returnMessage"] = returnData;
             return(RedirectToAction("Matrimony"));
         }
         ModelState.AddModelError(string.Empty, "There was an error completing the registration, Please check if the record is correct");
         return(View(model));
     }
     catch (Exception e)
     {
         //error occured
         ModelState.AddModelError(string.Empty, "There was an error completing the registration, Please try again later");
         ErrorUtil.LogError(e);
         return(View(model));
     }
 }
Exemple #3
0
        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));
            }
        }
Exemple #4
0
        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());
        }