Esempio n. 1
0
        }                                                                                      //End public void Create

        public void Update(EmployeedetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Employee oModel = db.Employees.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set Image file name
                    if (poFileimage != null)
                    {
                        if ((oModel.EMPLOYEE_IMG == null) || (oModel.EMPLOYEE_IMG == ""))
                        {
                            oModel.EMPLOYEE_IMG = Utility_FileUploadDownload.setImage_Employee();
                        }
                    }                                                                                                                                                                        //End if (poFileimage != null)
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.ID = oModel.ID;

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModel.EMPLOYEE_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
Esempio n. 2
0
        }                         //End public EmployeeCRUD()

        public void Create(EmployeedetailVM poViewModel, HttpPostedFileBase poFileimage = null)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Employee oModel = new Employee();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set Image file name
                    if (poFileimage != null)
                    {
                        oModel.EMPLOYEE_IMG = Utility_FileUploadDownload.setImage_Employee();
                    }                                                                                                  //End if (poFileimage != null)

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

                    //Save file
                    if (poFileimage != null)
                    {
                        Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModel.EMPLOYEE_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
Esempio n. 3
0
 //Constructor
 public Employee_Validation(EmployeedetailVM poViewModel)
 {
     oViewModel = poViewModel;
 } //End public Employee_Validation()