}                                                                                      //End public void Create

        public void Update(PhotogallerydetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Photogallery oModel = db.Photogallerys.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_DTA_STS_UPDATE;
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        if ((oModel.PHOTO_IMG == null) || (oModel.PHOTO_IMG == ""))
                        {
                            oModel.PHOTO_IMG = Utility_FileUploadDownload.setImage_Gallery();
                        }
                    }
                    { Utility_FileUploadDownload.saveImage_Gallery(poFileimage, oModel.PHOTO_IMG); } //End if (poFileimage != null)
                }                                                                                    //End using
            }                                                                                        //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; }         //End catch
        }                                                                                            //End public void Update
        }                             //End public PhotogalleryCRUD()

        public void Create(PhotogallerydetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Photogallery oModel = new Photogallery();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE;
                    //Set Image file name
                    oModel.PHOTO_IMG = Utility_FileUploadDownload.setImage_Gallery();

                    //Process CRUD
                    db.Photogallerys.Add(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Gallery(poFileimage, oModel.PHOTO_IMG);
                    }                                                                                //End if (poFileimage != null)
                } //End using
            } //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create