예제 #1
0
        public ActionResult Edit(CreateOrEditMemberViewModel viewModel)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList <MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts   = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList <MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones       = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList <MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals   = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList <MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts   = memberDistricts;
            viewModel.ddlMemberZones       = memberZones;
            viewModel.ddlMemberHospitals   = memberHospitals;

            try
            {
                if (ModelState.IsValid)
                {
                    var member = new OSNB.Models.Member {
                        Id = viewModel.MemberId, FirstName = viewModel.FirstName, LastName = viewModel.LastName, SurName = viewModel.SurName, DateOfBirth = viewModel.DateOfBirth, Address = viewModel.Address, PhoneNumber = viewModel.PhoneNumber, MobileNumber = viewModel.MobileNumber, ThumbImageUrl = viewModel.ThumbImageUrl, SmallImageUrl = viewModel.SmallImageUrl, MemberBloodGroupId = viewModel.MemberBloodGroupId, MemberDistrictId = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId, MemberZoneId = viewModel.MemberZoneId, MemberHospitalId = viewModel.MemberHospitalId, UserName = viewModel.UserName
                    };

                    _db.Entry(member).State = EntityState.Modified;
                    _db.SaveChanges();

                    return(RedirectToAction("Index", "Member"));
                    //return Content(Boolean.TrueString);
                }

                return(Content(ExceptionHelper.ModelStateErrorFormat(ModelState)));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return(Content("Sorry! Unable to edit this member."));
            }
        }
예제 #2
0
        public ActionResult AddMember(CreateOrEditMemberViewModel viewModel)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList <MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts   = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList <MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones       = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList <MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals   = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList <MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();
            var memberStatues     = SelectListItemExtension.PopulateDropdownList(_db.MemberStatues.ToList <MemberStatus>(), "Id", "MemberStatusTitle").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts   = memberDistricts;
            viewModel.ddlMemberZones       = memberZones;
            viewModel.ddlMemberHospitals   = memberHospitals;
            viewModel.ddlMemberStatus      = memberStatues;

            try
            {
                if (ModelState.IsValid)
                {
                    var file = viewModel.ImageFile;

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName     = Path.GetFileName(file.FileName);
                        var physicalPath = Path.Combine(Server.MapPath("~/Images"), fileName);

                        // The files are not actually saved in this demo
                        file.SaveAs(physicalPath);

                        string imageUrl = @"/Images/" + fileName;

                        viewModel.SmallImageUrl = imageUrl;
                        viewModel.ThumbImageUrl = imageUrl;
                    }

                    var memberStatus     = _db.MemberStatues.SingleOrDefault(x => x.Id == viewModel.MemberStatusId);
                    var memberStatusList = new List <MemberStatus>();
                    memberStatusList.Add(memberStatus);

                    OSNB.Models.Member model = new OSNB.Models.Member {
                        FirstName = viewModel.FirstName, LastName = viewModel.LastName, SurName = viewModel.SurName, DateOfBirth = viewModel.DateOfBirth, Address = viewModel.Address, PhoneNumber = viewModel.PhoneNumber, MobileNumber = viewModel.MobileNumber, ThumbImageUrl = viewModel.ThumbImageUrl, SmallImageUrl = viewModel.SmallImageUrl, UserName = viewModel.UserName, MemberBloodGroupId = viewModel.MemberBloodGroupId, MemberDistrictId = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId, MemberZoneId = viewModel.MemberZoneId, MemberHospitalId = viewModel.MemberHospitalId, MemberStatues = memberStatusList
                    };

                    _db.Members.Add(model);
                    _db.SaveChanges();

                    return(RedirectToAction("Index", "Member"));
                }

                //return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
                return(View(viewModel));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return(View(viewModel));
            }
        }
예제 #3
0
        public ActionResult Register(RegisterViewModel model)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList <MemberBloodGroup>(), "Id", "BloodGroupName").ToList();
            var memberDistricts   = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList <MemberDistrict>(), "Id", "DistrictName").ToList();
            var memberZones       = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Selected = true, Text = "- Select -", Value = "0"
                }
            }.ToList();
            var memberHospitals = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList <MemberHospital>(), "Id", "HospitalName").ToList();

            model.ddlMemberBloodGroups = memberBloodGroups;
            model.ddlMemberDistricts   = memberDistricts;
            model.ddlMemberZones       = memberZones;
            model.ddlMemberHospitals   = memberHospitals;

            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    OSNB.Models.User user = _db.Users.Find(model.UserName);
                    OSNB.Models.Role role = _db.Roles.Find("User");
                    user.Roles = new List <Role> {
                        role
                    };

                    _db.Entry(user).State = EntityState.Modified;

                    OSNB.Models.Member member = new OSNB.Models.Member {
                        FirstName = model.UserName, LastName = null, SurName = model.UserName, DateOfBirth = null, Address = null, PhoneNumber = null, MobileNumber = model.ContactNo, ThumbImageUrl = null, SmallImageUrl = null, UserName = model.UserName, MemberBloodGroupId = model.MemberBloodGroupId, MemberDistrictId = model.MemberDistrictId, MemberHospitalId = model.MemberHospitalId, MemberZoneId = model.MemberZoneId
                    };

                    _db.Members.Add(member);
                    _db.SaveChanges();

                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #4
0
        public ActionResult Edit(CreateOrEditMemberViewModel viewModel)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList<MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList<MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList<MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList<MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts = memberDistricts;
            viewModel.ddlMemberZones = memberZones;
            viewModel.ddlMemberHospitals = memberHospitals;

            try
            {
                if (ModelState.IsValid)
                {
                    var member = new OSNB.Models.Member { Id = viewModel.MemberId, FirstName = viewModel.FirstName, LastName = viewModel.LastName, SurName = viewModel.SurName, DateOfBirth = viewModel.DateOfBirth, Address = viewModel.Address, PhoneNumber = viewModel.PhoneNumber, MobileNumber = viewModel.MobileNumber, ThumbImageUrl = viewModel.ThumbImageUrl, SmallImageUrl = viewModel.SmallImageUrl, MemberBloodGroupId = viewModel.MemberBloodGroupId, MemberDistrictId = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId, MemberZoneId = viewModel.MemberZoneId, MemberHospitalId = viewModel.MemberHospitalId, UserName = viewModel.UserName };

                    _db.Entry(member).State = EntityState.Modified;
                    _db.SaveChanges();

                    return RedirectToAction("Index", "Member");
                    //return Content(Boolean.TrueString);
                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return Content("Sorry! Unable to edit this member.");
            }
        }
예제 #5
0
        public ActionResult Edit(CreateOrEditMemberViewModel viewModel, HttpPostedFileBase ImageFile)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList <MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts   = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList <MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones       = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList <MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals   = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList <MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();
            var memberStatues     = SelectListItemExtension.PopulateDropdownList(_db.MemberStatues.ToList <MemberStatus>(), "Id", "MemberStatusTitle").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts   = memberDistricts;
            viewModel.ddlMemberZones       = memberZones;
            viewModel.ddlMemberHospitals   = memberHospitals;
            viewModel.ddlMemberStatus      = memberStatues;

            try
            {
                if (ModelState.IsValid)
                {
                    //you can put your existing save code here
                    if (ImageFile != null && ImageFile.ContentLength > 0)
                    {
                        var uploadDir = "~/Images";
                        var imagePath = Path.Combine(Server.MapPath(uploadDir), ImageFile.FileName);
                        var imageUrl  = Path.Combine(uploadDir, ImageFile.FileName);

                        ImageFile.SaveAs(imagePath);

                        var imageFile = @"/Images/" + ImageFile.FileName;

                        viewModel.ThumbImageUrl = imageFile;
                        viewModel.SmallImageUrl = imageFile;
                    }


                    var memberStatus     = _db.MemberStatues.SingleOrDefault(x => x.Id == viewModel.MemberStatusId);
                    var memberStatusList = new List <MemberStatus>();
                    memberStatusList.Add(memberStatus);

                    var member = new OSNB.Models.Member
                    {
                        Id                 = viewModel.MemberId,
                        FirstName          = viewModel.FirstName,
                        LastName           = viewModel.LastName,
                        SurName            = viewModel.SurName,
                        DateOfBirth        = viewModel.DateOfBirth,
                        Address            = viewModel.Address,
                        PhoneNumber        = viewModel.PhoneNumber,
                        MobileNumber       = viewModel.MobileNumber,
                        ThumbImageUrl      = viewModel.ThumbImageUrl,
                        SmallImageUrl      = viewModel.SmallImageUrl,
                        MemberBloodGroupId = viewModel.MemberBloodGroupId,
                        MemberDistrictId   = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId,
                        MemberZoneId       = viewModel.MemberZoneId,
                        MemberHospitalId   = viewModel.MemberHospitalId,
                        UserName           = viewModel.UserName,
                        MemberStatues      = memberStatusList
                    };

                    _db.Entry(member).State = EntityState.Modified;
                    _db.SaveChanges();

                    return(RedirectToAction("Index", "Member"));
                    //return Content(Boolean.TrueString);
                }

                return(Content(ExceptionHelper.ModelStateErrorFormat(ModelState)));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return(Content("Sorry! Unable to edit this member."));
            }
        }
예제 #6
0
        public ActionResult Register(RegisterViewModel model)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList<MemberBloodGroup>(), "Id", "BloodGroupName").ToList();
            var memberDistricts = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList<MemberDistrict>(), "Id", "DistrictName").ToList();
            var memberZones = new List<SelectListItem>() { new SelectListItem() { Selected = true, Text = "- Select -", Value = "0" } }.ToList();
            var memberHospitals = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList<MemberHospital>(), "Id", "HospitalName").ToList();
            model.ddlMemberBloodGroups = memberBloodGroups;
            model.ddlMemberDistricts = memberDistricts;
            model.ddlMemberZones = memberZones;
            model.ddlMemberHospitals = memberHospitals;

            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    OSNB.Models.User user = _db.Users.Find(model.UserName);
                    OSNB.Models.Role role = _db.Roles.Find("User");
                    user.Roles = new List<Role> { role };

                    _db.Entry(user).State = EntityState.Modified;

                    OSNB.Models.Member member = new OSNB.Models.Member { FirstName = model.UserName, LastName = null, SurName = model.UserName, DateOfBirth = null, Address = null, PhoneNumber = null, MobileNumber = model.ContactNo, ThumbImageUrl = null, SmallImageUrl = null, UserName = model.UserName, MemberBloodGroupId = model.MemberBloodGroupId, MemberDistrictId = model.MemberDistrictId, MemberHospitalId = model.MemberHospitalId, MemberZoneId = model.MemberZoneId };

                    _db.Members.Add(member);
                    _db.SaveChanges();

                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #7
0
        public ActionResult Edit(CreateOrEditMemberViewModel viewModel, HttpPostedFileBase ImageFile)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList<MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList<MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList<MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList<MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();
            var memberStatues = SelectListItemExtension.PopulateDropdownList(_db.MemberStatues.ToList<MemberStatus>(), "Id", "MemberStatusTitle").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts = memberDistricts;
            viewModel.ddlMemberZones = memberZones;
            viewModel.ddlMemberHospitals = memberHospitals;
            viewModel.ddlMemberStatus = memberStatues;

            try
            {
                if (ModelState.IsValid)
                {
                    //you can put your existing save code here
                    if (ImageFile != null && ImageFile.ContentLength > 0)
                    {
                        var uploadDir = "~/Images";
                        var imagePath = Path.Combine(Server.MapPath(uploadDir), ImageFile.FileName);
                        var imageUrl = Path.Combine(uploadDir, ImageFile.FileName);

                        ImageFile.SaveAs(imagePath);

                        var imageFile = @"/Images/" + ImageFile.FileName;

                        viewModel.ThumbImageUrl = imageFile;
                        viewModel.SmallImageUrl = imageFile;
                    }

                    var memberStatus = _db.MemberStatues.SingleOrDefault(x => x.Id == viewModel.MemberStatusId);
                    var memberStatusList = new List<MemberStatus>();
                    memberStatusList.Add(memberStatus);

                    var member = new OSNB.Models.Member
                                 {
                                     Id = viewModel.MemberId,
                                     FirstName = viewModel.FirstName,
                                     LastName = viewModel.LastName,
                                     SurName = viewModel.SurName,
                                     DateOfBirth = viewModel.DateOfBirth,
                                     Address = viewModel.Address,
                                     PhoneNumber = viewModel.PhoneNumber,
                                     MobileNumber = viewModel.MobileNumber,
                                     ThumbImageUrl = viewModel.ThumbImageUrl,
                                     SmallImageUrl = viewModel.SmallImageUrl,
                                     MemberBloodGroupId = viewModel.MemberBloodGroupId,
                                     MemberDistrictId = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId,
                                     MemberZoneId = viewModel.MemberZoneId,
                                     MemberHospitalId = viewModel.MemberHospitalId,
                                     UserName = viewModel.UserName,
                                     MemberStatues = memberStatusList
                                 };

                    _db.Entry(member).State = EntityState.Modified;
                    _db.SaveChanges();

                    return RedirectToAction("Index", "Member");
                    //return Content(Boolean.TrueString);
                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return Content("Sorry! Unable to edit this member.");
            }
        }
예제 #8
0
        public ActionResult AddMember(CreateOrEditMemberViewModel viewModel)
        {
            var memberBloodGroups = SelectListItemExtension.PopulateDropdownList(_db.MemberBloodGroups.ToList<MemberBloodGroup>(), "Id", "BloodGroupName", isEdit: true, selectedValue: viewModel.MemberBloodGroupId != 0 ? viewModel.MemberBloodGroupId.ToString() : "0").ToList();
            var memberDistricts = SelectListItemExtension.PopulateDropdownList(_db.MemberDistricts.ToList<MemberDistrict>(), "Id", "DistrictName", isEdit: true, selectedValue: viewModel.MemberDistrictId != 0 ? viewModel.MemberDistrictId.ToString() : "0").ToList();
            var memberZones = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList<MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: viewModel.MemberZoneId != 0 ? viewModel.MemberZoneId.ToString() : "0").ToList();
            var memberHospitals = SelectListItemExtension.PopulateDropdownList(_db.MemberHospitals.ToList<MemberHospital>(), "Id", "HospitalName", isEdit: true, selectedValue: viewModel.MemberHospitalId != 0 ? viewModel.MemberHospitalId.ToString() : "0").ToList();
            var memberStatues = SelectListItemExtension.PopulateDropdownList(_db.MemberStatues.ToList<MemberStatus>(), "Id", "MemberStatusTitle").ToList();

            viewModel.ddlMemberBloodGroups = memberBloodGroups;
            viewModel.ddlMemberDistricts = memberDistricts;
            viewModel.ddlMemberZones = memberZones;
            viewModel.ddlMemberHospitals = memberHospitals;
            viewModel.ddlMemberStatus = memberStatues;

            try
            {
                if (ModelState.IsValid)
                {
                    var file = viewModel.ImageFile;

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var physicalPath = Path.Combine(Server.MapPath("~/Images"), fileName);

                        // The files are not actually saved in this demo
                        file.SaveAs(physicalPath);

                        string imageUrl = @"/Images/" + fileName;

                        viewModel.SmallImageUrl = imageUrl;
                        viewModel.ThumbImageUrl = imageUrl;
                    }

                    var memberStatus = _db.MemberStatues.SingleOrDefault(x => x.Id == viewModel.MemberStatusId);
                    var memberStatusList = new List<MemberStatus>();
                    memberStatusList.Add(memberStatus);

                    OSNB.Models.Member model = new OSNB.Models.Member { FirstName = viewModel.FirstName, LastName = viewModel.LastName, SurName = viewModel.SurName, DateOfBirth = viewModel.DateOfBirth, Address = viewModel.Address, PhoneNumber = viewModel.PhoneNumber, MobileNumber = viewModel.MobileNumber, ThumbImageUrl = viewModel.ThumbImageUrl, SmallImageUrl = viewModel.SmallImageUrl, UserName = viewModel.UserName, MemberBloodGroupId = viewModel.MemberBloodGroupId, MemberDistrictId = viewModel.MemberDistrictId == 0 ? 1 : viewModel.MemberDistrictId, MemberZoneId = viewModel.MemberZoneId, MemberHospitalId = viewModel.MemberHospitalId, MemberStatues = memberStatusList };

                    _db.Members.Add(model);
                    _db.SaveChanges();

                    return RedirectToAction("Index", "Member");
                }

                //return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
                return View(viewModel);
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return View(viewModel);
            }
        }