Esempio n. 1
0
        //BloodGroupInfo
        public ActionResult BloodGroupInfo(int id)
        {
            var memberBloodGroup = _db.MemberBloodGroups.Find(id);

            var memberBloodGroupViewModel = new MemberBloodGroupViewModel { Id = memberBloodGroup.Id, BloodGroupName = memberBloodGroup.BloodGroupName };

            return View(memberBloodGroupViewModel);
        }
        public ActionResult Add(MemberBloodGroupViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var memberBloodGroup = new MemberBloodGroup { Id = viewModel.Id, BloodGroupName = viewModel.BloodGroupName };

                    _db.MemberBloodGroups.Add(memberBloodGroup);
                    _db.SaveChanges();

                    return Content(Boolean.TrueString);
                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return Content("Sorry! Unable to add this member blood group.");
            }
        }
        //
        // GET: /MemberBloodGroup/Delete/By ID
        public ActionResult Delete(int id)
        {
            try
            {
                var memberBloodGroup = _db.MemberBloodGroups.Find(id);
                if (memberBloodGroup != null)
                {
                    var memberBloodGroupViewModel = new MemberBloodGroupViewModel { Id = memberBloodGroup.Id, BloodGroupName = memberBloodGroup.BloodGroupName };

                    return PartialView("_Delete", memberBloodGroupViewModel);
                }
                else
                {
                    return RedirectToAction("Index", "MemberBloodGroup");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "MemberBloodGroup");
            }
        }