示例#1
0
 public Guid Add(Supplier entity)
 {
     using (OpenPOSDbEntities ctx = new OpenPOSDbEntities())
     {
         try
         {
             ctx.Suppliers.AddObject(entity);
             ctx.SaveChanges();
             return entity.Id;
         }
         catch (Exception ex)
         {
             LogService.Error("Error while adding Supplier", ex);
             throw new ArgumentException("Error while adding new Supplier!");
         }
     }
 }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Suppliers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSuppliers(Supplier supplier)
 {
     base.AddObject("Suppliers", supplier);
 }
示例#3
0
        public void Update(Supplier entity)
        {
            if (entity.Id.Equals(Guid.Empty))
                throw new ArgumentException("Supplier Id cannot be empty!");

            using (OpenPOSDbEntities ctx = new OpenPOSDbEntities())
            {
                try
                {

                    ctx.Suppliers.Attach(entity);

                    ctx.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified);

                    ctx.Suppliers.ApplyCurrentValues(entity);

                    ctx.SaveChanges();

                }
                catch (Exception ex)
                {
                    LogService.Error("Error while updating Supplier", ex);
                    throw ex;
                }
            }
        }
示例#4
0
 /// <summary>
 /// Create a new Supplier object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="contactDetailId">Initial value of the ContactDetailId property.</param>
 public static Supplier CreateSupplier(global::System.Guid id, global::System.String name, global::System.Boolean status, global::System.Guid contactDetailId)
 {
     Supplier supplier = new Supplier();
     supplier.Id = id;
     supplier.Name = name;
     supplier.Status = status;
     supplier.ContactDetailId = contactDetailId;
     return supplier;
 }