Пример #1
0
 public void CreateMemberBiodata(tbl_member_biodata member)
 {
     using (var scope = new TransactionScope())
     {
         _memberbiodatarepository.insert(member);
         _memberbiodatarepository.CommitChanges();
         scope.Complete();
     }
 }
Пример #2
0
        public bool UpdateMemberBiodata(tbl_member_biodata members)
        {
            var success = false;

            if (members != null)
            {
                using (var scope = new TransactionScope())
                {
                    _memberbiodatarepository.Update(members);
                    _memberbiodatarepository.CommitChanges();
                    scope.Complete();
                    success = true;
                }
            }

            return(success);
        }
Пример #3
0
        public ActionResult saveBiodata(HttpPostedFileBase pics, Member_BiodataVM data)
        {
            var image = pics;

            byte[] imageData = null;
            try
            {
                if (image == null)
                {
                    FileInfo   _file      = new FileInfo(Server.MapPath("~") + "\\customview\\html\\images\\gallery\\image2.jpg");
                    FileStream _fileSream = new FileStream(_file.FullName, FileMode.Open);
                    imageData  = new byte[_fileSream.Length];
                    data.photo = imageData;
                }
                else
                {
                    //Declare byte array for holding images to bytlike file


                    //geth extention
                    var filename = Path.GetExtension(image.FileName);

                    //validate extension
                    if (!_biodataservice.ValidateExtension(filename))
                    {
                        Information("upload image with Extention .jpg|.png|.jpeg");
                        return(RedirectToAction("creatememberbiodata", "MemberBiodata", new { area = "Admin" }));
                    }

                    // read image to binary files
                    using (var binaryReader = new BinaryReader(image.InputStream))
                    {
                        imageData = binaryReader.ReadBytes(image.ContentLength);
                        var headerImage = new HeaderImage()
                        {
                            ImageData = imageData,
                            ImageName = image.FileName,
                            IsActive  = true
                        };
                        //var data = Convert.ToBase64String(imageData);
                        data.photo = imageData;
                    }
                }//end of else

                if (data.id == 0)
                {
                    tbl_member_biodata memberBiodata = new tbl_member_biodata();
                    memberBiodata.first_name                = data.first_name.ToUpper();
                    memberBiodata.last_name                 = data.last_name.ToUpper();
                    memberBiodata.middle_name               = data.middle_name.ToUpper();
                    memberBiodata.dob                       = data.dob;
                    memberBiodata.phone_number              = data.phone_number;
                    memberBiodata.house_address             = data.house_address.ToUpper();
                    memberBiodata.marital_status            = data.marital_status.ToUpper();
                    memberBiodata.house_fellowship_id       = data.house_fellowship_id;
                    memberBiodata.date_of_initial_attendant = data.date_of_initial_attendant;
                    memberBiodata.gender                    = data.gender.ToUpper();
                    memberBiodata.photo                     = data.photo;
                    _biodataservice.CreateMemberBiodata(memberBiodata);
                }
                else
                {
                    var tblbiodata = _biodataservice.findMember(data.id);
                    if (tblbiodata == null)
                    {
                        Danger("Member biodata cannot be found", true);
                        return(RedirectToAction("membersbiodatas"));
                    }

                    tblbiodata.first_name                = data.first_name.ToUpper();
                    tblbiodata.last_name                 = data.last_name.ToUpper();
                    tblbiodata.middle_name               = data.middle_name.ToUpper();
                    tblbiodata.dob                       = data.dob;
                    tblbiodata.phone_number              = data.phone_number;
                    tblbiodata.house_address             = data.house_address.ToUpper();
                    tblbiodata.marital_status            = data.marital_status.ToUpper();
                    tblbiodata.house_fellowship_id       = data.house_fellowship_id;
                    tblbiodata.date_of_initial_attendant = data.date_of_initial_attendant;
                    tblbiodata.gender                    = data.gender.ToUpper();
                    tblbiodata.photo                     = data.photo;
                    _biodataservice.UpdateMemberBiodata(tblbiodata);
                    Success("Member Biodata updateed successfully", true);
                    return(RedirectToAction("membersbiodatas", "MemberBiodata", new { area = "Admin" }));
                }
            }

            catch (DbEntityValidationException e)
            {
                Exception raise = e;

                var outputLines = new List <string>();
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var valerror in eve.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}", eve.Entry.Entity.ToString(),
                                                       valerror.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }

                throw raise;
            }
            Success("Member Biodata created successfully", true);
            return(RedirectToAction("creatememberbiodata", "MemberBiodata", new { area = "Admin" }));
        }