internal Local_Database.Rating ConvertToDBRating(SharedDataTypes.Rating r)
 {
     if (r.type)
     {
         return new Local_Database.Rating
                {
                    ID_Rating    = r.RatingId,
                    Chocolate_ID = r.ProductId,
                    Customer_ID  = r.Customer.CustomerId,
                    Comment      = r.Comment,
                    Published    = r.Published,
                    Date         = r.Date,
                    ModifyDate   = DateTime.Now
                }
     }
     ;
     else
     {
         return new Local_Database.Rating
                {
                    ID_Rating   = r.RatingId,
                    Package_ID  = r.ProductId,
                    Customer_ID = r.Customer.CustomerId,
                    Comment     = r.Comment,
                    Published   = r.Published,
                    Date        = r.Date,
                    ModifyDate  = DateTime.Now
                }
     };
 }
        public bool UpdateRating(SharedDataTypes.Rating r)
        {
            var temp = mainDb.Rating.Where(p => p.ID_Rating.Equals(r.RatingId)).Select(p => p).First();

            temp.Value = r.Value;
            temp.Date  = r.Date;
            //temp.Package_ID = r.Package.PackageId;
            //temp.Chocolate_ID = r.Chocolate.ChocolateId;
            temp.Customer_ID = r.Customer.CustomerId;
            temp.Comment     = r.Comment;
            temp.Published   = r.Published;
            temp.ModifyDate  = DateTime.Now;

            return(mainDb.SaveChanges() == 1);
        }
Exemple #3
0
        //not all are implemented
        #region UPDATE METHODS
        public bool UpdateRating(SharedDataTypes.Rating r)
        {
            var temp = localDb.Rating.Where(p => p.ID_Rating.Equals(r.RatingId)).Select(p => p).First();

            temp.Value = r.Value;
            temp.Date  = r.Date;
            if (temp.Package != null)
            {
                temp.Package_ID = r.ProductId;
            }
            if (temp.Chocolate != null)
            {
                temp.Chocolate_ID = r.ProductId;
            }
            temp.Customer_ID = r.Customer.CustomerId;
            temp.Comment     = r.Comment;
            temp.Published   = r.Published;
            temp.ModifyDate  = DateTime.Now;

            return(localDb.SaveChanges() == 1);
        }
Exemple #4
0
 public bool InsertRating(SharedDataTypes.Rating r)
 {
     localDb.Rating.Add(converter.ConvertToDBRating(r));
     return(localDb.SaveChanges() == 1);
 }
Exemple #5
0
 public bool UpdateRating(SharedDataTypes.Rating r)
 {
     return(mainDh.UpdateRating(r));
 }