private static Invoice getEntityByModel(InvoiceModel model) { if (model == null) return null; Invoice entity = new Invoice(); 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.ConversionRate = model.ConversionRate; entity.CurrencyId = model.CurrencyId; entity.CustomerId = model.CustomerId; entity.CustomerSiteId = model.CustomerSiteId; entity.Id = model.Id; entity.InvoiceDate = model.InvoiceDate; entity.InvoiceNo = model.InvoiceNo; entity.InvoiceType = model.InvoiceType; entity.PeriodId = model.PeriodId; entity.Remarks = model.Remarks; entity.SOBId = model.SOBId; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return entity; }
public string Update(Invoice entity) { Invoice originalEntity = this.Context.Invoices.Find(entity.Id); this.Context.Entry(originalEntity).CurrentValues.SetValues(entity); this.Context.Entry(originalEntity).State = EntityState.Modified; this.Commit(); return entity.Id.ToString(); }
public InvoiceModel(Invoice entity) { this.CompanyId = entity.CompanyId; this.ConversionRate = entity.ConversionRate; this.CurrencyId = entity.CurrencyId; this.CustomerId = entity.CustomerId; this.CustomerSiteId = entity.CustomerSiteId; this.Id = entity.Id; this.InvoiceDate = entity.InvoiceDate; this.InvoiceNo = entity.InvoiceNo; this.InvoiceType = entity.InvoiceType; this.PeriodId = entity.PeriodId; this.Remarks = entity.Remarks; this.SOBId = entity.SOBId; this.CreateBy = entity.CreateBy; this.CreateDate = entity.CreateDate; this.UpdateBy = entity.UpdateBy; this.UpdateDate = entity.UpdateDate; this.CurrencyName = ""; this.PeriodName = ""; this.Customers = new List<SelectListItem>(); this.CustomerSites = new List<SelectListItem>(); this.Periods = new List<SelectListItem>(); this.Currencies = new List<SelectListItem>(); }
public string Insert(Invoice entity) { this.Context.Invoices.Add(entity); this.Commit(); return entity.Id.ToString(); }
public string Update(Invoice entity) { return this.repository.Update(entity); }
public string Insert(Invoice entity) { return this.repository.Insert(entity); }