예제 #1
0
        public TblTrailerTruck InsertTblTrailerTruckToDataBase(TblTrailerTruck nTrailer)
        {
            try
            {
                if (nTrailer != null)
                {
                    nTrailer.CreateDate = this.DateOfServer;
                    nTrailer.Creator    = nTrailer.Creator ?? "someone";

                    this.Context.TblTrailerTruck.Add(nTrailer);
                    return(this.Context.SaveChanges() > 0 ? this.GetTblTrailerTruckWithKey(nTrailer.TrailerId) : null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Has error " + ex.ToString());
            }
            return(null);
        }
예제 #2
0
        public TblTrailerTruck UpdateTblTrailerTruckToDataBase(int TrailerID, TblTrailerTruck uTrailer)
        {
            try
            {
                var dbTrailer = this.Context.TblTrailerTruck.Find(TrailerID);
                if (dbTrailer != null)
                {
                    uTrailer.CreateDate = dbTrailer.CreateDate;
                    uTrailer.ModifyDate = this.DateOfServer;
                    uTrailer.Modifyer   = uTrailer.Modifyer ?? "someone";

                    this.Context.Entry(dbTrailer).CurrentValues.SetValues(uTrailer);
                    return(this.Context.SaveChanges() > 0 ? this.GetTblTrailerTruckWithKey(TrailerID) : null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Has error " + ex.ToString());
            }
            return(null);
        }