public HttpResponseMessage Put(Register r)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;
            RegistersDA.UpdateRegister(r, p.Claims);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }
        public HttpResponseMessage Post(Register r)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;
            int id = RegistersDA.InsertRegister(r, p.Claims);

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
            message.Content = new StringContent(id.ToString());
            return message;
        }
 public static Register GetRegisterByID(int id, IEnumerable<Claim> claims)
 {
     Register reg = new Register();
     string sql = "SELECT * FROM Register WHERE ID=@ID";
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", id);
     DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parID);
     reader.Read();
     reg = CreateClient(reader);
     reader.Close();
     return reg;
 }
 public static Register GetRegisterByID(int id)
 {
     Register reg = new Register();
     string sql = "SELECT * FROM Register WHERE ID=@ID";
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", id);
     DbDataReader reader = Database.GetData(Database.GetConnection(Database.ADMIN_DB), sql, parID);
     while (reader.Read())
     {
         reg = Create(reader);
     }
     reader.Close();
     return reg;
 }
Example #5
0
 public static List<Sale> GetSalesByCustRegProdID(Customer c, Register r, Product p, IEnumerable<Claim> claims)
 {
     List<Sale> list = new List<Sale>();
     string sql = "SELECT * FROM Sale WHERE CustomerID=@CID And RegisterID=@RID And ProductID=@PID";
     DbParameter parCID = Database.AddParameter(Database.ADMIN_DB, "@CID", c.ID);
     DbParameter parRID = Database.AddParameter(Database.ADMIN_DB, "@RID", r.ID);
     DbParameter parPID = Database.AddParameter(Database.ADMIN_DB, "@PID", p.ID);
     DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parCID, parRID, parPID);
     while (reader.Read())
     {
         list.Add(Create(reader));
     }
     reader.Close();
     return list;
 }
 public int Put(Register r)
 {
     return RegistersDA.UpdateRegister(r);
 }
 public int Post(Register r)
 {
     return RegistersDA.InsertRegister(r);
 }
Example #8
0
 public static List<Sale> GetSalesByRegisterID(Register r, IEnumerable<Claim> claims)
 {
     List<Sale> list = new List<Sale>();
     string sql = "SELECT * FROM Sale WHERE RegisterID=@ID";
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", r.ID);
     DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql,parID);
     while (reader.Read())
     {
         list.Add(Create(reader));
     }
     reader.Close();
     return list;
 }
 public static int InsertRegister(Register reg)
 {
     string sql = "INSERT INTO Register VALUES(@RegisterName,@Device,@PurchaseDate,@ExpiresDate)";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterName", reg.RegisterName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Device", reg.Device);
     DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@PurchaseDate", reg.PurchaseDate);
     DbParameter par4 = Database.AddParameter(Database.ADMIN_DB, "@ExpiresDate", reg.ExpiresDate);
     return Database.InsertData(Database.GetConnection(Database.ADMIN_DB), sql, par1, par2, par3, par4);
 }
 public static int InsertRegister(Register reg, IEnumerable<Claim> claims)
 {
     string sql = "INSERT INTO Register VALUES(@RegisterName,@Device,@PurchaseDate,@ExpiresDate)";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterName", reg.RegisterName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Device", reg.Device);
     return Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2);
 }
 public static int UpdateRegister(Register reg)
 {
     string sql = "UPDATE Register SET RegisterName=@RegisterName, Device=@Device, PurchaseDate=@PurchaseDate, ExpiresDate=@ExpiresDate WHERE ID=@ID";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterName", reg.RegisterName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Device", reg.Device);
     DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@PurchaseDate", reg.PurchaseDate);
     DbParameter par4 = Database.AddParameter(Database.ADMIN_DB, "@ExpiresDate", reg.ExpiresDate);
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", reg.ID);
     return Database.ModifyData(Database.GetConnection(Database.ADMIN_DB), sql, par1, par2, par3, par4, parID);
 }
 public static int UpdateRegister(Register reg, IEnumerable<Claim> claims)
 {
     string sql = "UPDATE Register SET RegisterName=@RegisterName, Device=@Device WHERE ID=@ID";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@RegisterName", reg.RegisterName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Device", reg.Device);
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", reg.ID);
     return Database.ModifyData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, parID);
 }