Exemplo n.º 1
0
 public virtual HttpResponseMessage GetLogin(string login, string password)
 {
     using (AriUMContext ctx = new AriUMContext("AriUMDBConnection"))
     {
         WebApiTicket tck = CntWebApiSecurity.Login(login,password,30,ctx);
         if (tck == null)
         {
             return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Nombre de usuario o contraseña incorrecto");
         }
         else
         {
             // we must add the new ticket to the database
             ctx.Add(tck);
             ctx.SaveChanges();
             tck = ctx.CreateDetachedCopy<WebApiTicket>(tck, x => x.User);
             return Request.CreateResponse<WebApiTicket>(HttpStatusCode.OK, tck);
         }
     }
 }
Exemplo n.º 2
0
 public static bool DeleteProduct(Product product, AriUMContext ctx)
 {
     ctx.Delete(product);
     ctx.SaveChanges();
     return true;
 }
Exemplo n.º 3
0
 public static UserGroup PutUserGroup(UserGroup userGroup, AriUMContext ctx)
 {
     ctx.AttachCopy<UserGroup>(userGroup);
     ctx.SaveChanges();
     return userGroup;
 }
Exemplo n.º 4
0
 public static User PutUser(User user, AriUMContext ctx)
 {
     // Password control
     if (user.Password != "" && user.Password != null)
     {
         user.Password = CntWebApiSecurity.GetHashCode(user.Password);
     }
     ctx.AttachCopy<User>(user);
     ctx.SaveChanges();
     return user;
 }
Exemplo n.º 5
0
 public static bool DeleteInvoiceLine(InvoiceLine invoiceLine, AriUMContext ctx)
 {
     ctx.Delete(invoiceLine);
     ctx.SaveChanges();
     return true;
 }
Exemplo n.º 6
0
 public static Product PutProduct(Product product, AriUMContext ctx)
 {
     ctx.AttachCopy<Product>(product);
     ctx.SaveChanges();
     return product;
 }
Exemplo n.º 7
0
 public static InvoiceLine PutInvoiceLine(InvoiceLine invoiceLine, AriUMContext ctx)
 {
     int invoiceLineId = invoiceLine.InvoiceLineId;
     int productId = 0;
     int invoiceId = 0;
     if (invoiceLine.Product != null)
     {
         productId = invoiceLine.Product.ProductId;
         invoiceLine.Product = null;
     }
     if (invoiceLine.Invoice != null)
     {
         invoiceId = invoiceLine.Invoice.InvoiceId;
         invoiceLine.Invoice = null;
     }
     ctx.AttachCopy<InvoiceLine>(invoiceLine);
     invoiceLine = (from il in ctx.InvoiceLines
                    where il.InvoiceLineId == invoiceLineId
                    select il).FirstOrDefault<InvoiceLine>();
     invoiceLine.Product = (from p in ctx.Products
                            where p.ProductId == productId
                            select p).FirstOrDefault<Product>();
     invoiceLine.Invoice = (from i in ctx.Invoices
                            where i.InvoiceId == invoiceId
                            select i).FirstOrDefault<Invoice>();
     ctx.SaveChanges();
     return invoiceLine;
 }
Exemplo n.º 8
0
 public static bool DeleteCustomer(Customer customer, AriUMContext ctx)
 {
     ctx.Delete(customer);
     ctx.SaveChanges();
     return true;
 }
Exemplo n.º 9
0
 public static Customer PutCustomer(Customer customer, AriUMContext ctx)
 {
     ctx.AttachCopy<Customer>(customer);
     ctx.SaveChanges();
     return customer;
 }
Exemplo n.º 10
0
 public static UserGroup PostUserGroup(UserGroup userGroup, AriUMContext ctx)
 {
     ctx.Add(userGroup);
     ctx.SaveChanges();
     return userGroup;
 }
Exemplo n.º 11
0
 public static Product PostProduct(Product product, AriUMContext ctx)
 {
     ctx.Add(product);
     ctx.SaveChanges();
     return product;
 }
Exemplo n.º 12
0
 public static InvoiceLine PostInvoiceLine(InvoiceLine invoiceLine, AriUMContext ctx)
 {
     if (invoiceLine.Invoice != null)
     {
         Invoice invoice = (from i in ctx.Invoices
                            where i.InvoiceId == invoiceLine.Invoice.InvoiceId
                            select i).FirstOrDefault<Invoice>();
         invoiceLine.Invoice = invoice;
     }
     if (invoiceLine.Product != null)
     {
         Product product = (from p in ctx.Products
                            where p.ProductId == invoiceLine.Product.ProductId
                            select p).FirstOrDefault<Product>();
         invoiceLine.Product = product;
     }
     ctx.Add(invoiceLine);
     ctx.SaveChanges();
     return invoiceLine;
 }
Exemplo n.º 13
0
 public static Invoice PostInvoice(Invoice invoice, AriUMContext ctx)
 {
     ctx.Add(invoice);
     ctx.SaveChanges();
     return invoice;
 }
Exemplo n.º 14
0
 public static Customer PostCustomer(Customer customer, AriUMContext ctx)
 {
     ctx.Add(customer);
     ctx.SaveChanges();
     return customer;
 }
Exemplo n.º 15
0
 public static bool DeleteUser(User user, AriUMContext ctx)
 {
     ctx.Delete(user);
     ctx.SaveChanges();
     return true;
 }
Exemplo n.º 16
0
 public static bool DeleteUserGroup(UserGroup userGroup, AriUMContext ctx)
 {
     ctx.Delete(userGroup);
     ctx.SaveChanges();
     return true;
 }
Exemplo n.º 17
0
 public static Invoice PutInvoice(Invoice invoice, AriUMContext ctx)
 {
     //Customer c = invoice.Customer;
     //invoice.Customer = null;
     //ctx.AttachCopy<Invoice>(invoice);
     //invoice.Customer = c;
     int customerId = 0;
     int invoiceId = invoice.InvoiceId;
     if (invoice.Customer != null)
     {
         customerId = invoice.Customer.CustomerId;
         invoice.Customer = null;
     }
     ctx.AttachCopy <Invoice>(invoice);
     if (customerId != 0)
     {
         invoice = (from i in ctx.Invoices
                    where i.InvoiceId == invoiceId
                    select i).FirstOrDefault<Invoice>();
         invoice.Customer = (from cus in ctx.Customers
                             where cus.CustomerId == customerId
                             select cus).FirstOrDefault<Customer>();
     }
     ctx.SaveChanges();
     return invoice;
 }