Пример #1
0
        /*===INSERT CONTROLLER===*/
        public bool insertNewPromotion(string productCode, float promotionPrice, DateTime startTime, DateTime endTime, string promotionContent, string promotionImage)
        {
            try
            {
                using (var db = new CMART2Entities1())
                {
                    ObjectParameter idoutput = new ObjectParameter("Code", typeof(String));
                    db.SP_PROMOTIONINFORMATION_ID_AUTO(idoutput);
                    var id_auto = idoutput.Value.ToString();

                    var promotion = new PromotionInformation
                    {
                        PromotionCode  = id_auto,
                        ProductCode    = productCode,
                        PricePromotion = promotionPrice,
                        StartTime      = startTime,
                        EndTime        = endTime,
                        Cont           = promotionContent,
                        Image          = promotionImage
                    };
                    db.PromotionInformations.Add(promotion);
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }