Example #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!");
         }
     }
 }
 /// <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);
 }
Example #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;
                }
            }
        }
 /// <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;
 }