Example #1
0
        public bool insertAll(Int16 costumerid, string name, Int16 orderid, DateTime data, string produs, Decimal valoareOD, Int16 serial, string adress = "", Decimal valoareO = -1)
        {
            bool insert = false;

            using (var testEntities = new TestEntities())
            {
                CUSTOMER c = new CUSTOMER();
                c.CUSTOMERID = costumerid;
                if (testEntities.CUSTOMER.Where(x => x.CUSTOMERID == c.CUSTOMERID).Count() <= 0)
                {
                    c.NAME   = name;
                    c.ADRESA = adress;
                    if (testEntities.ORDER.Where(x => x.ORDERID == orderid).Count() <= 0 && testEntities.ORDERDETAILS.Where(x => x.SERIAL == serial).Count() <= 0)
                    {// nu exita conflicte
                        ORDER o = new ORDER {
                            ORDERID = orderid, DATA = data, CUSTOMERID = costumerid, VALOARE = valoareO
                        };
                        c.ORDER.Add(o);
                        o.ORDERDETAILS.Add(new ORDERDETAILS {
                            ORDERID = orderid, PRODUS = produs, VALOARE = valoareOD, SERIAL = serial
                        });

                        testEntities.AddToCUSTOMER(c);
                        testEntities.SaveChanges();
                        insert = true;
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(insert);
        }
Example #2
0
 public bool addCostumer(Int16 id, string name, string adress = "")
 {
     using (var testEntities = new TestEntities())
     {
         CUSTOMER c = new CUSTOMER();
         c.CUSTOMERID = id;
         // verificam daca mai exista un asemena id in bd
         if (testEntities.CUSTOMER.Where(x => x.CUSTOMERID == c.CUSTOMERID).Count() <= 0)
         {
             c.NAME   = name;
             c.ADRESA = adress;
             testEntities.AddToCUSTOMER(c);
             testEntities.SaveChanges();
         }
         else
         {
             return(false);
         }
     }
     return(true); // clientul a fost adauga
 }