Exemplo n.º 1
0
        //public List<SharedDataTypes.Rating> QueryRatingsByPackageId(Guid PackageId)
        //{
        //    return converter.ConvertToSharedRatings(mainDb.Rating.Where(p => p.Package_ID.Equals(PackageId)).Select(p => p).ToList());
        //}

        //public List<SharedDataTypes.Rating> QueryRatingsByChocoId(Guid ChocoId)
        //{
        //    return converter.ConvertToSharedRatings(mainDb.Rating.Where(p => p.Chocolate_ID.Equals(ChocoId)).Select(p => p).ToList());
        //}


        #endregion

        #region INSERT METHODS

        public bool InsertChocolate(SharedDataTypes.Chocolate c)
        {
            c.ChocolateId = Guid.NewGuid();
            mainDb.Chocolate.Add(converter.ConvertToDBChoco(c));
            int cnt = 1;

            foreach (var item in c.Ingredients)
            {
                cnt++;
                mainDb.Chocolate_has_Ingridients.Add(converter.ConvertToDBChocolateHasIngredients(c.ChocolateId, item.IngredientId));
            }
            return(mainDb.SaveChanges() == cnt);
        }
Exemplo n.º 2
0
        public bool UpdateChocolate(SharedDataTypes.Chocolate c)
        {
            var temp = localDb.Chocolate.Where(p => p.ID_Chocolate.Equals(c.ChocolateId)).Select(p => p).First();

            temp.Name                = c.Name;
            temp.Description         = c.Description;
            temp.Available           = c.Available;
            temp.Image               = c.Image;
            temp.WrappingID          = c.Wrapping.WrappingId;
            temp.Shape_ID            = c.Shape.ShapeId;
            temp.Creator_Customer_ID = c.CreatedBy.CustomerId;
            temp.ModifyDate          = DateTime.Now;

            return(localDb.SaveChanges() == 1);
        }
Exemplo n.º 3
0
        public bool UpdateChocolate(SharedDataTypes.Chocolate c)
        {
            var temp = mainDb.Chocolate.Where(p => p.ID_Chocolate.Equals(c.ChocolateId)).Select(p => p).First();

            temp.Name                = (c.Name == null)?temp.Name:c.Name;
            temp.Description         = (c.Description == null)?temp.Description:c.Description;
            temp.Available           = c.Available;
            temp.Image               = (c.Image.Equals(""))?temp.Image:c.Image;
            temp.WrappingID          = (c.Wrapping == null)?temp.Wrapping.ID_Wrapping:c.Wrapping.WrappingId;
            temp.Shape_ID            = (c.Shape == null)?temp.Shape.ID_Shape:c.Shape.ShapeId;
            temp.ModifyDate          = DateTime.Now;
            temp.Creator_Customer_ID = (c.CreatedBy == null)?temp.Creator_Customer_ID:c.CreatedBy.CustomerId;

            return(mainDb.SaveChanges() == 1);
        }
Exemplo n.º 4
0
 public DataBases.Chocolate ConvertToDBChoco(SharedDataTypes.Chocolate c)
 {
     return(new DataBases.Chocolate
     {
         ID_Chocolate = c.ChocolateId,
         Name = c.Name,
         Description = c.Description,
         Available = c.Available,
         Shape_ID = c.Shape.ShapeId,
         CustomStyle_ID = c.CustomStyle.CustomStyleId,
         Image = c.Image,
         Creator_Customer_ID = c.CreatedBy.CustomerId,
         ModifyDate = DateTime.Now,
         WrappingID = c.Wrapping.WrappingId,
     });
 }
Exemplo n.º 5
0
 internal Local_Database.OrderContent_has_Chocolate ConvertToDBOcHasChoco(SharedDataTypes.OrderContent oc, SharedDataTypes.Chocolate c)
 {
     return(new OrderContent_has_Chocolate
     {
         OrderContent_ID = oc.OrderContentId,
         Amount = oc.Amount,
         Chocolate_ID = c.ChocolateId,
         ModifyDate = DateTime.Now
     });
 }