示例#1
0
 public override string ToString()
 {
     return("Dish ID: " + DishID.ToString()
            + "\n Dish name: " + DishName
            + "\n Dish size: " + DishSize.ToString()
            + "\n Dish price: " + DishPrice.ToString()
            + "\n Kashrut level: " + KashrutLevel.ToString()
            + "\n Preparing time: " + PreparingTime.Hours.ToString() + ":" + PreparingTime.Minutes.ToString());
 }
示例#2
0
 public DishBean InjectionPrice(DishPrice bean)
 {
     this.Price1       = bean.Price1;
     this.Price2       = bean.Price2;
     this.Price3       = bean.Price3;
     this.MemberPrice3 = bean.MemberPrice3;
     this.MemberPrice2 = bean.MemberPrice2;
     this.MemberPrice1 = bean.MemberPrice1;
     return(this);
 }
        public DishBeanUtil CreateDishBeanUtilByDishBean(DishPrice bean)
        {
            this.DishId       = bean.DishId;
            this.Price1       = bean.Price1;
            this.Price2       = bean.Price2;
            this.Price3       = bean.Price3;
            this.MemberPrice3 = bean.MemberPrice3;
            this.MemberPrice2 = bean.MemberPrice2;
            this.MemberPrice1 = bean.MemberPrice1;
            this.DishFormat   = bean.DishSpecification;

            return(this);
        }
 public DishPriceBean CreateDishPriceBean(DishPrice bean)
 {
     this.Id                = bean.Id;
     this.DishId            = bean.DishId;
     this.DishSpecification = bean.DishSpecification;
     this.Price1            = bean.Price1;
     this.Price2            = bean.Price2;
     this.Price3            = bean.Price3;
     this.MemberPrice3      = bean.MemberPrice3;
     this.MemberPrice2      = bean.MemberPrice2;
     this.MemberPrice1      = bean.MemberPrice1;
     this.IsMainPrice       = bean.IsMainPrice;
     this.Dish              = bean.Dish;
     return(this);
 }
        public static DishPrice GetDishPrice(this IRepositoryAsync <MfdDishPriceRelations> repository, double price)
        {
            DishPrice dishPrice =
                repository.GetRepositoryAsync <DishPrice>()
                .Queryable()
                .FirstOrDefault(dp => Math.Abs(dp.Price - price) < 0.001);

            if (dishPrice == null)
            {
                dishPrice = new DishPrice {
                    Price = price
                };
                repository.Context.Entry(dishPrice).State = EntityState.Added;
            }
            return(dishPrice);
        }
        public DishPrice CreateDishPrice(DishPriceBean bean)
        {
            DishPrice beanBack = new DishPrice();

            beanBack.Id                = bean.Id;
            beanBack.DishId            = bean.DishId;
            beanBack.DishSpecification = bean.DishSpecification;
            beanBack.Price1            = bean.Price1;
            beanBack.Price2            = bean.Price2;
            beanBack.Price3            = bean.Price3;
            beanBack.MemberPrice3      = bean.MemberPrice3;
            beanBack.MemberPrice2      = bean.MemberPrice2;
            beanBack.MemberPrice1      = bean.MemberPrice1;
            beanBack.IsMainPrice       = bean.IsMainPrice;
            beanBack.Dish              = bean.Dish;
            return(beanBack);
        }
示例#7
0
        public DishPrice CreateDishPrice(DishBean bean)
        {
            DishPrice beanBack = new DishPrice();

            beanBack.DishId            = bean.DishId;
            beanBack.DishSpecification = bean.DishFormat;
            beanBack.Price1            = bean.Price1;
            beanBack.Price2            = bean.Price2;
            beanBack.Price3            = bean.Price3;
            beanBack.MemberPrice3      = bean.MemberPrice3;
            beanBack.MemberPrice2      = bean.MemberPrice2;
            beanBack.MemberPrice1      = bean.MemberPrice1;
            beanBack.CreateTime        = DateTime.Now;
            beanBack.IsMainPrice       = 1;
            beanBack.Deleted           = 0;
            beanBack.CreateBy          = bean.CreateBy;
            beanBack.Update_by         = bean.UpdateBy;
            beanBack.UpdateTime        = bean.UpdateDatetime;
            return(beanBack);
        }
        //修改逻辑
        public void UpdateDishesObject()
        {
            //修改菜品
            if (SelectedDishUnitItem != null)
            {
                //修改菜品单位
                _DishBean.DishUnitId = SelectedDishUnitItem.DishUnitId;
            }
            _DishBean.UpdateDatetime = DateTime.Now;
            _DishBean.UpdateBy       = SubjectUtils.GetAuthenticationId();
            bool flag = _DataService.updateDish(_DishBean.CreateDish(_DishBean));

            if (flag)
            {
                //修改菜品价格
                DishPrice dp = _DishBean.CreateDishPrice(_DishBean);
                //修改菜品主价格
                _DataService.UpdateDishPriceMain(dp);
                //批量修改菜品价格
                if (!IsEditDishPrice)
                {
                    foreach (var element in _DishePriceList)
                    {
                        element.CreateBy   = 1;
                        element.DishId     = _DishBean.DishId;
                        element.CreateTime = DateTime.Now;
                    }
                    _DataService.UpdateDishPrice(_DishBean.DishId, _DishePriceList.ToArray());
                }
                //重新加载所有数据
                LoadDishBase(_DishTypeIdLast);
                //关闭窗口
                AddDishWin.Close();
            }
            else
            {
                MessageBox.Show("修改菜品失败!");
            }
        }
        //根据菜品id 和 菜品价格id 修改菜品价格 
        public bool UpdateDishPrice(int DishId, DishPrice[] dishPrices)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                foreach (var dishPrice in dishPrices)
                {
                    if (dishPrice.IsMainPrice != 1) { 
                        var type = entities.DishPrice.SingleOrDefault(bt => bt.Id == dishPrice.Id);
                        if (type != null)
                        {
                            type.Price1 = dishPrice.Price1;
                            type.Price2 = dishPrice.Price2;
                            type.Price3 = dishPrice.Price3;
                            type.MemberPrice1 = dishPrice.MemberPrice1;
                            type.MemberPrice2 = dishPrice.MemberPrice2;
                            type.MemberPrice3 = dishPrice.MemberPrice3;
                            type.Update_by = SubjectUtils.GetAuthenticationId();
                            type.UpdateTime = DateTime.Now;
                            entities.SaveChanges();
                        }
                        else {
                            dishPrice.CreateTime = DateTime.Now;
                            entities.DishPrice.Add(dishPrice);
                            entities.SaveChanges();
                        }
                    }
                }

            }
            return true;
        }
        //根据菜品id 和 菜品价格id 删除菜品价格 
        public bool DeleteDishPrice(DishPrice dishPrice)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                var type = entities.DishPrice.SingleOrDefault(bt => bt.DishId == dishPrice.DishId && bt.IsMainPrice != 1&&bt.Id ==dishPrice.Id);
                if (type != null)
                {
                    type.Deleted = 1;
                    type.Update_by = SubjectUtils.GetAuthenticationId();
                    type.UpdateTime = DateTime.Now;
                    entities.SaveChanges();
                }
            }

            return true;
        }
        //根据 一个 菜品 id 和菜品价格集合 新增 菜品价格 
        public bool SaveDishPrice(int DishId, DishPrice[] dishPrices)
        {
            if (dishPrices != null) {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    for (int i = 0; i < dishPrices.Length; i++)
                    {

                            entities.DishPrice.Add(dishPrices[i]);
                            entities.SaveChanges();
                        
                    }
                }
               
            }

            return false;
        }
 //修改菜品主价格
 public bool UpdateDishPriceMain(DishPrice dishPrice) {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var type = entities.DishPrice.SingleOrDefault(bt => bt.DishId == dishPrice.DishId && bt.IsMainPrice == 1);
         if (type != null)
         {
             type.Price1 = dishPrice.Price1;
             type.Price2 = dishPrice.Price2;
             type.Price3 = dishPrice.Price3;
             type.MemberPrice1 = dishPrice.MemberPrice1;
             type.MemberPrice2 = dishPrice.MemberPrice2;
             type.MemberPrice3 = dishPrice.MemberPrice3;
             type.Update_by = SubjectUtils.GetAuthenticationId();
             type.UpdateTime = DateTime.Now;
             entities.SaveChanges();
         }
         else 
         {
             entities.DishPrice.Add(dishPrice);
             entities.SaveChanges();
         }
     }
     return true;
 
 }
示例#13
0
        public DishBeanUtil CreateDishBeanUtilByDishBean(DishPrice bean)
        {
            this.DishId = bean.DishId;
            this.Price1 = bean.Price1;
            this.Price2 = bean.Price2;
            this.Price3 = bean.Price3;
            this.MemberPrice3 = bean.MemberPrice3;
            this.MemberPrice2 = bean.MemberPrice2;
            this.MemberPrice1 = bean.MemberPrice1;
            this.DishFormat = bean.DishSpecification;

            return this;
        }
        public DishPrice CreateDishPrice(DishPriceBean bean)
        {
            DishPrice beanBack = new DishPrice();
            beanBack.Id = bean.Id;
            beanBack.DishId = bean.DishId;
            beanBack.DishSpecification = bean.DishSpecification;
            beanBack.Price1 = bean.Price1;
            beanBack.Price2 = bean.Price2;
            beanBack.Price3 = bean.Price3;
            beanBack.MemberPrice3 = bean.MemberPrice3;
            beanBack.MemberPrice2 = bean.MemberPrice2;
            beanBack.MemberPrice1 = bean.MemberPrice1;
            beanBack.IsMainPrice = bean.IsMainPrice;
            beanBack.Dish = bean.Dish;
            return beanBack;

        }
        public DishPriceBean CreateDishPriceBean(DishPrice bean)
        {
            this.Id = bean.Id;
            this.DishId = bean.DishId;
            this.DishSpecification = bean.DishSpecification;
            this.Price1 = bean.Price1;
            this.Price2 = bean.Price2;
            this.Price3 = bean.Price3;
            this.MemberPrice3 = bean.MemberPrice3;
            this.MemberPrice2 = bean.MemberPrice2;
            this.MemberPrice1 = bean.MemberPrice1;
            this.IsMainPrice = bean.IsMainPrice;
            this.Dish = bean.Dish;
            return this;

        }
示例#16
0
        public DishPrice CreateDishPrice(DishBean bean)
        {
            DishPrice beanBack = new DishPrice();
            beanBack.DishId = bean.DishId;
            beanBack.DishSpecification = bean.DishFormat;
            beanBack.Price1 = bean.Price1;
            beanBack.Price2 = bean.Price2;
            beanBack.Price3 = bean.Price3;
            beanBack.MemberPrice3 = bean.MemberPrice3;
            beanBack.MemberPrice2 = bean.MemberPrice2;
            beanBack.MemberPrice1 = bean.MemberPrice1;
            beanBack.CreateTime = DateTime.Now;
            beanBack.IsMainPrice = 1;
            beanBack.Deleted = 0;
            beanBack.CreateBy = bean.CreateBy;
            beanBack.Update_by = bean.UpdateBy;
            beanBack.UpdateTime = bean.UpdateDatetime;
            return beanBack;

        }
示例#17
0
 public DishBean InjectionPrice(DishPrice bean) {
     this.Price1 = bean.Price1;
     this.Price2 = bean.Price2;
     this.Price3 = bean.Price3;
     this.MemberPrice3 = bean.MemberPrice3;
     this.MemberPrice2 = bean.MemberPrice2;
     this.MemberPrice1 = bean.MemberPrice1; 
     return this;
 }
        public static void InitializeIdentityForEf(ApplicationDbContext context, string path)
        {
            context.DishQuantities.AddOrUpdate(dq => dq.Quantity,
                                               new DishQuantity {
                Quantity = 0.0
            },
                                               new DishQuantity {
                Quantity = 0.5
            },
                                               new DishQuantity {
                Quantity = 1.0
            },
                                               new DishQuantity {
                Quantity = 1.5
            },
                                               new DishQuantity {
                Quantity = 2.0
            },
                                               new DishQuantity {
                Quantity = 3.0
            },
                                               new DishQuantity {
                Quantity = 4.0
            },
                                               new DishQuantity {
                Quantity = 5.0
            }
                                               );


            context.DishTypes.AddOrUpdate(dt => dt.Category,
                                          new DishType {
                Category = "Первое"
            },
                                          new DishType {
                Category = "Второе"
            },
                                          new DishType {
                Category = "Салат"
            },
                                          new DishType {
                Category = "Напиток"
            }
                                          );

            context.Days.AddOrUpdate(d => d.Name,
                                     new DayOfWeek {
                Name = "Понедельник"
            },
                                     new DayOfWeek {
                Name = "Вторник"
            },
                                     new DayOfWeek {
                Name = "Среда"
            },
                                     new DayOfWeek {
                Name = "Четверг"
            },
                                     new DayOfWeek {
                Name = "Пятница"
            },
                                     new DayOfWeek {
                Name = "Суббота"
            },
                                     new DayOfWeek {
                Name = "Воскресенье"
            }
                                     );


            var userManager = new ApplicationUserManager(new UserStore <User>(context));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));


            if (!roleManager.RoleExists("SuperUser"))
            {
                roleManager.Create(new UserRole
                {
                    Name        = "SuperUser",
                    Description = "Can Update List Employee and DiningEmployee"
                });
            }
            if (!roleManager.RoleExists("Employee"))
            {
                roleManager.Create(new UserRole
                {
                    Name        = "Employee",
                    Description = "Сan order food in the dining room"
                });
            }


            string sulogin = WebConfigurationManager.AppSettings["sulogin"];
            User   usersu  = userManager.FindByName(sulogin);

            if (usersu == null)
            {
                usersu = new User
                {
                    UserName         = sulogin,
                    Email            = "*****@*****.**",
                    FirstName        = "admin",
                    LastName         = "super",
                    SecurityStamp    = Guid.NewGuid().ToString(),
                    LastLoginTime    = DateTime.UtcNow,
                    RegistrationDate = DateTime.UtcNow,
                    PasswordHash     =
                        userManager.PasswordHasher.HashPassword(WebConfigurationManager.AppSettings["supass"])
                };
                IdentityRole role = context.Roles.FirstOrDefault(r => string.Equals(r.Name, "SuperUser"));
                usersu.Roles.Add(new IdentityUserRole {
                    RoleId = role.Id, UserId = usersu.Id
                });
                context.Entry(usersu).State = EntityState.Added;
            }


            User userEmpl = userManager.FindByName("employee");

            if (userEmpl == null)
            {
                userEmpl = new User
                {
                    UserName         = "******",
                    Email            = "*****@*****.**",
                    FirstName        = "Employee",
                    LastName         = "User",
                    LastLoginTime    = DateTime.UtcNow,
                    SecurityStamp    = Guid.NewGuid().ToString(),
                    RegistrationDate = DateTime.UtcNow,
                    PasswordHash     = userManager.PasswordHasher.HashPassword("777123")
                };
                IdentityRole emplrole = context.Roles.FirstOrDefault(r => string.Equals(r.Name, "Employee"));
                userEmpl.Roles.Add(new IdentityUserRole {
                    RoleId = emplrole.Id, UserId = userEmpl.Id
                });
                context.Entry(userEmpl).State = EntityState.Added;
            }

            //пустые блюда для каждой категории
            List <DishType> dishTypes = context.DishTypes.OrderBy(dt => dt.Id).ToList();
            //пустые блюда для каждой категории
            DishPrice nulldp = new DishPrice {
                Price = 0.00
            };

            context.Dishes.AddRange(dishTypes.Select(dt => new Dish
            {
                DishType     = dt,
                CurrentPrice = nulldp
            }).ToArray());
            context.SaveChanges();
        }