Esempio n. 1
0
        public async Task <bool> Create(FoodGrouping FoodGrouping)
        {
            FoodGroupingDAO FoodGroupingDAO = new FoodGroupingDAO();

            FoodGroupingDAO.Id       = FoodGrouping.Id;
            FoodGroupingDAO.Name     = FoodGrouping.Name;
            FoodGroupingDAO.StatusId = FoodGrouping.StatusId;
            DataContext.FoodGrouping.Add(FoodGroupingDAO);
            await DataContext.SaveChangesAsync();

            FoodGrouping.Id = FoodGroupingDAO.Id;
            await SaveReference(FoodGrouping);

            return(true);
        }
Esempio n. 2
0
        public async Task <bool> BulkMerge(List <FoodGrouping> FoodGroupings)
        {
            List <FoodGroupingDAO> FoodGroupingDAOs = new List <FoodGroupingDAO>();

            foreach (FoodGrouping FoodGrouping in FoodGroupings)
            {
                FoodGroupingDAO FoodGroupingDAO = new FoodGroupingDAO();
                FoodGroupingDAO.Id       = FoodGrouping.Id;
                FoodGroupingDAO.Name     = FoodGrouping.Name;
                FoodGroupingDAO.StatusId = FoodGrouping.StatusId;
                FoodGroupingDAOs.Add(FoodGroupingDAO);
            }
            await DataContext.BulkMergeAsync(FoodGroupingDAOs);

            return(true);
        }
Esempio n. 3
0
        public async Task <bool> Update(FoodGrouping FoodGrouping)
        {
            FoodGroupingDAO FoodGroupingDAO = DataContext.FoodGrouping.Where(x => x.Id == FoodGrouping.Id).FirstOrDefault();

            if (FoodGroupingDAO == null)
            {
                return(false);
            }
            FoodGroupingDAO.Id       = FoodGrouping.Id;
            FoodGroupingDAO.Name     = FoodGrouping.Name;
            FoodGroupingDAO.StatusId = FoodGrouping.StatusId;
            await DataContext.SaveChangesAsync();

            await SaveReference(FoodGrouping);

            return(true);
        }