コード例 #1
0
        private static VendorSite GetEntityByModel(VendorSiteModel model)
        {
            if (model == null)
            {
                return(null);
            }
            VendorSite entity = new VendorSite();

            entity.Id                = model.Id;
            entity.Name              = model.Name;
            entity.Address           = model.Address;
            entity.CodeCombinationId = model.CodeCombinationId;
            entity.Contact           = model.Contact;
            if (model.Id == 0)
            {
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }
            entity.EndDate    = model.EndDate;
            entity.StartDate  = model.StartDate;
            entity.UpdateBy   = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            entity.VendorId   = model.VendorId;
            return(entity);
        }
コード例 #2
0
        public static long Save(VendorSiteModel model)
        {
            VendorSite entity = GetEntityByModel(model);

            return(model.Id > 0
                ? service.Update(entity)
                : service.Insert(entity));
        }
コード例 #3
0
        public long Update(VendorSite entity)
        {
            var originalEntity = this.Context.VendorSites.Find(entity.Id);

            this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
            this.Context.Entry(originalEntity).State = EntityState.Modified;
            this.Commit();
            return(entity.Id);
        }
コード例 #4
0
 public VendorSiteModel(VendorSite entity)
 {
     if (entity != null)
     {
         this.VendorId          = entity.VendorId;
         this.CodeCombinationId = entity.CodeCombinationId;
         this.Address           = entity.Address;
         this.Contact           = entity.Contact;
         this.Name       = entity.Name;
         this.EndDate    = entity.EndDate;
         this.Id         = entity.Id;
         this.StartDate  = entity.StartDate;
         this.CreateBy   = entity.CreateBy;
         this.CreateDate = entity.CreateDate;
         this.UpdateBy   = entity.UpdateBy;
         this.UpdateDate = entity.UpdateDate;
     }
 }
コード例 #5
0
 public long Insert(VendorSite entity)
 {
     this.Context.VendorSites.Add(entity);
     this.Commit();
     return(entity.Id);
 }
コード例 #6
0
 public long Update(VendorSite entity)
 {
     return(this.repository.Update(entity));
 }
コード例 #7
0
 public long Insert(VendorSite entity)
 {
     return(this.repository.Insert(entity));
 }