private static Withholding getEntityByModel(WithholdingModel model)
        {
            if (model == null) return null;

            Withholding entity = new Withholding();

            if (model.Id == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
                entity.CompanyId = AuthenticationHelper.CompanyId.Value;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
                entity.CompanyId = model.CompanyId;
            }

            entity.Code = model.WithholdingCode;
            entity.VendorSiteId = model.VendorSiteId;
            entity.VendorId = model.VendorId;
            entity.SOBId = model.SOBId;
            entity.Rate = model.Rate;
            entity.Description = model.Description;
            entity.DateTo = model.DateTo;
            entity.DateFrom = model.DateFrom;
            entity.CodeCombinitionId = model.CodeCombinitionId;
            entity.Id = model.Id;
            entity.UpdateBy = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            return entity;
        }
 public string Update(Withholding entity)
 {
     if (entity.IsValid())
         return this.repository.Update(entity);
     else
         return "Entity is not in valid state";
 }
 public string Update(Withholding entity)
 {
     var originalEntity = this.Context.Withholdings.Find(entity.Id);
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
 public WithholdingModel(Withholding entity)
 {
     this.Id = entity.Id;
     this.SOBId = entity.SOBId;
     this.CodeCombinitionId = entity.CodeCombinitionId;
     this.DateFrom = entity.DateFrom;
     this.DateTo = entity.DateTo;
     this.Description = entity.Description;
     this.Rate = entity.Rate;
     this.VendorId = entity.VendorId;
     this.VendorSiteId = entity.VendorSiteId;
     this.WithholdingCode = entity.Code;
     this.CompanyId = entity.CompanyId;
     this.CreateBy = entity.CreateBy;
     this.CreateDate = entity.CreateDate;
     this.UpdateBy = entity.UpdateBy;
     this.UpdateDate = entity.UpdateDate;
 }
 public string Insert(Withholding entity)
 {
     this.Context.Withholdings.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }