Example #1
0
        /// <summary>
        /// 菜单增加
        /// </summary>
        /// <param name="foodInfoAddViewModel"></param>
        /// <returns></returns>
        public int Food_Add(FoodInfoAddViewModel foodInfoAddViewModel)
        {
            var food_Info = _IMapper.Map <FoodInfoAddViewModel, Food_Info>(foodInfoAddViewModel);

            _IFoodInfoRepository.Add(food_Info);
            return(_IFoodInfoRepository.SaveChanges());
        }
Example #2
0
        /// <summary>
        /// 菜单增加
        /// </summary>
        /// <param name="foodInfoAddViewModel"></param>
        /// <returns></returns>
        public int Food_Add(FoodInfoAddViewModel foodInfoAddViewModel)
        {
            System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();
            var      t       = DateTime.Now;
            var      tt      = Convert.ToInt32(t.DayOfWeek) == 0 ? 7 : Convert.ToInt32(t.DayOfWeek);
            DateTime tmpDay1 = t.AddDays(8 - tt);

            //var t1 = DateTime.Parse("2020-12-31");


            int    NextweekOfYear = gc.GetWeekOfYear(tmpDay1, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            string year           = "";

            if (foodInfoAddViewModel.WeekNumber == "1" && NextweekOfYear == 1)
            {
                year = (DateTime.Now.Year + 1).ToString();
            }
            else
            {
                year = DateTime.Now.Year.ToString();
            }
            var food_Info = _IMapper.Map <FoodInfoAddViewModel, Food_Info>(foodInfoAddViewModel);

            food_Info.AddDate  = DateTime.Now;
            food_Info.status   = "0";
            food_Info.isDelete = "0";
            food_Info.Year     = year;
            _IFoodInfoRepository.Add(food_Info);
            return(_IFoodInfoRepository.SaveChanges());
        }