コード例 #1
0
ファイル: SkhCRUD_Services.cs プロジェクト: arinsuga/kindup
        }                                                                                    //End public void Update

        public void Delete(int?id)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Skh oModel = db.Skhs.Find(id);
                    db.Skhs.Remove(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Delete" + e.Message; } //End catch
        }                                                                                    //End public void Delete
コード例 #2
0
ファイル: SkhCRUD_Services.cs プロジェクト: arinsuga/kindup
        }                                                                                      //End public void Create

        public void Update(SkhdetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Skh oModel = db.Skhs.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID);
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                            //End using
            }                                                                                //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch
        }                                                                                    //End public void Update
コード例 #3
0
ファイル: SkhCRUD_Services.cs プロジェクト: arinsuga/kindup
        }                    //End public SkhCRUD()

        public void Create(SkhdetailVM poViewModel)
        {
            try
            {
                using (var db = new DBMAINContext())
                {
                    Skh oModel = new Skh();
                    //Map Form Data
                    oModel.InjectFrom(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Process CRUD
                    db.Skhs.Add(oModel);
                    db.SaveChanges();
                    this.ID = oModel.ID;
                }                                                                              //End using
            }                                                                                  //End try
            catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch
        }                                                                                      //End public void Create