Example #1
0
        public long Post(M.Product producto)
        {
            O.Product BDProduct = new O.Product
            {
                Name             = producto.Name,
                Type             = producto.Type,
                TypeDescription  = producto.TypeDescription,
                AttendantName    = producto.AttendantName,
                AttendantWebPage = producto.AttendantWebPage,
                AttendantEmail   = producto.AttendantEmail,
                AttendantPhone   = producto.AttendantPhone,
                Latitude         = producto.Latitude,
                Longitude        = producto.Longitude,
                Date             = producto.Date,
                Active           = producto.Active,
                CreationDate     = System.DateTime.Now,
                CreationHourZone = System.TimeZoneInfo.Local.ToString(),
                Avatar           = producto.Avatar,
                NameAvatar       = producto.NameAvatar,
                IdPackage        = producto.IdPackage
            };

            BD.Products.Add(BDProduct);
            BD.SaveChanges();

            return(BDProduct.Id);
        }
Example #2
0
        public M.Product[] Get(long idPackage)
        {
            var query = from PR in BD.Products
                        where (PR.IdPackage.Equals(idPackage))
                        select new { PR.Id, PR.Name, PR.Type, PR.TypeDescription, PR.AttendantName, PR.AttendantWebPage, PR.AttendantEmail, PR.AttendantPhone, PR.Date, PR.Active, PR.CreationDate, PR.CreationHourZone, PR.Avatar };

            var lista = query.ToArray();

            M.Product[] arrayProducts = new M.Product[lista.Length];

            for (int i = 0; i < lista.Length; i++)
            {
                M.Product temp = new M.Product
                {
                    Id               = lista[i].Id,
                    Name             = lista[i].Name,
                    Type             = lista[i].Type,
                    TypeDescription  = lista[i].TypeDescription,
                    AttendantName    = lista[i].AttendantName,
                    AttendantWebPage = lista[i].AttendantWebPage,
                    AttendantEmail   = lista[i].AttendantEmail,
                    AttendantPhone   = lista[i].AttendantPhone,
                    Date             = lista[i].Date,
                    Active           = lista[i].Active,
                    CreationDate     = lista[i].CreationDate,
                    CreationHourZone = lista[i].CreationHourZone,
                    Avatar           = lista[i].Avatar
                };

                arrayProducts[i] = temp;
            }

            return(arrayProducts);
        }