예제 #1
0
        // POST
        public Quotation CreateQuotation(Quotation quo)
        {
            // serialize
            counter += 1;

            if (String.IsNullOrEmpty(quo.CodClient) || String.IsNullOrEmpty(quo.CodProd) || quo.Quantity <= 0)
            {
                Console.Out.WriteLine("CodProd NULL o CodClient NULL o Cantidad <= 0 ");
                throw new Exception("CodProd NULL o CodClient NULL o Cantidad <= 0");
            }

            PricingBook    myBook      = _priceBookService.GetAllPrices().Result;
            List <Product> myPriceBook = myBook.Content;
            Product        precioProd  = myPriceBook.Find(pr => pr.ProductId == quo.CodProd);

            quo.Id = counter;
            //quo.Price = precioProd != null ? (precioProd.PromotionPrice != 0 ? precioProd.PromotionPrice : precioProd.Price) : 0;
            quo.Sale = false;

            _dbContext.AddQuotation(DTOMappers.MapGroupLD(quo));



            return(quo);
        }
예제 #2
0
        public List <Student> GetAllStudents()
        {
            List <Database_Layer.Models.Student> students = _dbContext.GetAll();

            // creamos el DTOMappers para evitar las ambiguedades
            return(DTOMappers.MapStudents(students));
        }
예제 #3
0
        // PUT
        public Quotation UpdateQuotation(Quotation quo)
        {
            if (quo.Id <= 0 || quo.Quantity <= 0 || (String.IsNullOrEmpty(quo.CodProd)))
            {
                Console.Out.WriteLine("Id o cantidad incorrecta o codigo de Producto erroneo");
                throw new Exception("Id cantidad incorrecta o codigo de Producto erroneo");
            }

            Data.Models.Quotation qu = _dbContext.UpdateQuotation(quo.Id, quo.CodProd, quo.Quantity);
            return(DTOMappers.MapQuotationDL(qu));
        }
예제 #4
0
        public List <Info> GetAllInfo()
        {
            /*string projectTitle = _config.GetSection("Project").GetSection("Title").Value;
             * string dbConnection = _config.GetConnectionString("Database");
             *
             * Console.Out.WriteLine($"We are connecting to.... {dbConnection}");*/

            List <Database.Models.Info> groups = _dbContext.GetAll();

            return(DTOMappers.MapStudent(groups));
        }
예제 #5
0
        public List <Student> CreatePerson(Student student)                                                   // a. Create User
        {
            if (String.IsNullOrEmpty(student.Name) || student.Name.Length > 50 || student.AvailableSlots < 0) // Punto 6 practica 4
            {
                throw new Exception();
            }
            List <Database_Layer.Models.Student> studentDAO = DTOMappers.MapStudentsDAO(
                new List <Student>()
            {
                student
            }
                );

            studentDAO = _dbContext.AddStudents(studentDAO);
            return(DTOMappers.MapStudents(studentDAO));
        }
예제 #6
0
        // GET
        public List <Quotation> GetAllQuotations()
        {
            PricingBook    myBook      = _priceBookService.GetAllPrices().Result;
            List <Product> myPriceBook = myBook.Content;
            List <Data.Models.Quotation> quotations = _dbContext.GetAllQuotations();
            List <Quotation>             quots      = DTOMappers.MapQuotations(quotations);

            Console.Out.WriteLine("=================LISTA DE PRECIOS: ====================");
            foreach (var p in myPriceBook)
            {
                Console.WriteLine($"Precio CodProd: {p.ProductId} SetPrice: {p.FixedPrice} PromotionPrice: {p.PromotionPrice}");
            }

            Console.Out.WriteLine("==================LISTA DE COTIZACIONES===================");
            foreach (var qu in quots)
            {
                Product precioProd = myPriceBook.Find(pr => pr.ProductId == qu.CodProd);
                double  miPrecio   = 0;
                if (precioProd != null)
                {
                    if (precioProd.PromotionPrice == 0)
                    {
                        miPrecio = precioProd.FixedPrice;
                    }
                    else
                    {
                        miPrecio = precioProd.PromotionPrice;
                    }
                }
                else
                {
                    Console.WriteLine($"NO SE ENCONTRO EL CODIGO: {qu.CodProd}");
                }
                qu.Price = miPrecio;
                //qu.Price = miPrecio;
                Console.Out.WriteLine($"Id: {qu.Id} CodProd: {qu.CodProd} CodCliente: {qu.CodClient}" /*Price: {qu.Price}"*/);
            }


            return(quots);
        }
예제 #7
0
        public List <Quotation> GetAllQuotations()
        {
            List <Data.Models.Quotation> quo = _dbContext.GetAllQuotations();
            List <Price> myPriceBook         = _priceBookService.GetAllPrices().Result;

            Console.Out.WriteLine("=================LISTA DE PRECIOS: ====================");
            foreach (var p in myPriceBook)
            {
                Console.WriteLine($"Precio CodProd: {p.CodProd} SetPrice: {p.SetPrice} PromotionPrice: {p.PromotionPrice}");
            }

            Console.Out.WriteLine("==================LISTA DE COTIZACIONES===================");
            foreach (var prod in quo)
            {
                Price  precioProd = myPriceBook.Find(pr => pr.CodProd == prod.CodProd);
                double miPrecio   = 0;
                if (precioProd != null)
                {
                    if (precioProd.PromotionPrice == 0)
                    {
                        miPrecio = precioProd.SetPrice;
                    }
                    else
                    {
                        miPrecio = precioProd.PromotionPrice;
                    }
                }
                else
                {
                    Console.WriteLine($"NO SE ENCONTRO EL CODIGO: {prod.CodProd}");
                }

                prod.Price = miPrecio;
                Console.Out.WriteLine($"CodProd: {prod.CodProd} CodCliente: {prod.CodClient} Price: {prod.Price}");
            }

            return(DTOMappers.MapQuotations(quo));
        }
예제 #8
0
 public List <Client> UpdateClient(Client client)
 {
     if (client.Nombre == "")
     {
         ClientAttrException e = new ClientAttrException("No puede dejar el nombre vacio");
         Log.Error("Se produjo un error" + e.StackTrace + e.Message);
         throw e;
     }
     if (!(1000000 < client.CI && client.CI < 100000000))
     {
         ClientAttrException e = new ClientAttrException("Carnet de identidad invalido");
         Log.Error("Se produjo un error" + e.StackTrace + e.Message);
         throw e;
     }
     if (!(0 < client.Ranking && client.Ranking < 6))
     {
         ClientAttrException e = new ClientAttrException("Ranking es invalido");
         Log.Error("Se produjo un error" + e.StackTrace + e.Message);
         throw e;
     }
     client.Codigo = GenerateCode(client);
     return(DTOMappers.MapClients(_dbContext.UpdateClient(DTOMappers.MapClientLD(client))));
 }
예제 #9
0
 public Quotation CreateQuotation(Quotation quo)
 {
     _dbContext.AddQuotation(DTOMappers.MapGroupLD(quo));
     return(quo);
 }
예제 #10
0
        public List <Person> GetAllInfo()
        {
            List <Database.Models.Person> person = _dbContext.GetAll();

            return(DTOMappers.MapPerson(person));
        }
예제 #11
0
        public List <Group> GetAllInfo()
        {
            List <Database.Models.Group> group = _dbContext.GetAll();

            return(DTOMappers.MapGroup(group));
        }
예제 #12
0
 public List <Client> DeleteClient(int clientId)
 {
     return(DTOMappers.MapClients(_dbContext.DeleteClient(clientId)));
 }
예제 #13
0
 public Quotation UpdateSaleFalse(int id)
 {
     Data.Models.Quotation qu = _dbContext.UpdateSaleFalse(id);
     return(DTOMappers.MapQuotationDL(qu));
 }
예제 #14
0
        public List <Student> GetAllStudents()
        {
            List <Database_Layer.Models.Student> students = _dbContext.GetAll();

            return(DTOMappers.MapStudents(students));
        }
예제 #15
0
 public List <Client> GetAllClients()
 {
     return(DTOMappers.MapClients(_dbContext.GetAllClients()));
 }
예제 #16
0
 public Quotation UpdateQuotation(Quotation quo)
 {
     Data.Models.Quotation qu = _dbContext.UpdateQuotation(DTOMappers.MapGroupLD(quo));
     return(DTOMappers.MapQuotationDL(qu));
 }
예제 #17
0
        public List <Client> GetCClients()
        {
            var CClients = DTOMappers.MapCClients(_clientsService.GetAll(_config).Result);

            return(CClients);
        }