public async Task <IActionResult> PutRestaurant(int id, Restaurant restaurant)
        {
            if (id != restaurant.Id)
            {
                return(BadRequest());
            }

            _context.Entry(restaurant).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestaurantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        //public async Task<PagingResult<Customer>> GetCustomersPageAsync(int skip, int take)
        //{
        //    var totalRecords = await _Context.Customers.CountAsync();
        //    var customers = await _Context.Customers
        //                         .OrderBy(c => c.LastName)
        //                         .Include(c => c.State)
        //                         .Include(c => c.Orders)
        //                         .Skip(skip)
        //                         .Take(take)
        //                         .ToListAsync();
        //    return new PagingResult<Customer>(customers, totalRecords);
        //}
        public async Task <PeriodicElement> InsertPeriodicElementAsync(PeriodicElement element)
        {
            _context.Add(element);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (System.Exception exp)
            {
                _Logger.LogError($"Error in {nameof(InsertPeriodicElementAsync)}: " + exp.Message);
            }

            return(element);
        }
示例#3
0
        public async Task <Customer> InsertCustomerAsync(Customer customer)
        {
            _Context.Add(customer);
            try
            {
                await _Context.SaveChangesAsync();
            }
            catch (System.Exception exp)
            {
                _Logger.LogError($"Error in {nameof(InsertCustomerAsync)}: " + exp.Message);
            }

            return(customer);
        }
示例#4
0
        public async Task <ActionResult <Order> > Post([FromBody] Order order)
        {
            if (order != null)
            {
                db.Orders.Add(order);
                await db.SaveChangesAsync();

                return(Ok("Created Successfully"));
            }
            else
            {
                return(BadRequest("Order was missing some field's maybe"));
            }
        }
示例#5
0
        public async Task <IActionResult> Register(Vendors Vendors)
        {
            //var userWithSameEmail = _dbContext.ADMINMast.SingleOrDefault(u => u.EmailID == ADMINMast.EmailID);
            //if (userWithSameEmail != null) return BadRequest("User with this email already exists");
            var VendorsObj = new Vendors
            {
                VendorID          = Guid.NewGuid(),
                Active            = Vendors.Active,
                CityID            = Vendors.CityID,
                DeliveryProvision = Vendors.DeliveryProvision,
                LocationMAP       = Vendors.LocationMAP,
                Password          = Vendors.Password,
                RegionID          = Vendors.RegionID,
                UserName          = Vendors.UserName,
                VendorAddress     = Vendors.VendorAddress,
                VendorCode        = Vendors.VendorCode,
                VendorEmail       = Vendors.VendorEmail,
                VendorFName       = Vendors.VendorFName,
                VendorLName       = Vendors.VendorLName,
                VendorPhone1      = Vendors.VendorPhone1,
                VendorPhone2      = Vendors.VendorPhone2
            };

            _dbContext.Vendors.Add(VendorsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#6
0
        public async Task <IActionResult> Register(Items Items)
        {
            var ItemWithSameSame = _dbContext.Items.SingleOrDefault(u => u.ItemName == Items.ItemName);

            if (ItemWithSameSame != null)
            {
                return(BadRequest("Item with this name already exists"));
            }
            var ItemsObj = new Items
            {
                ItemID          = Guid.NewGuid(),
                ItemAddOnID     = Items.ItemAddOnID,
                ItemCode        = Items.ItemCode,
                ItemDescription = Items.ItemDescription,
                ItemImage       = Items.ItemImage,
                ItemName        = Items.ItemName,
                ItemPrice       = Items.ItemPrice,
                ItemTypeID      = Items.ItemTypeID,
                StarReceipe     = Items.StarReceipe,
                VegNonVeg       = Items.VegNonVeg
            };

            _dbContext.Items.Add(ItemsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#7
0
        public async Task <IActionResult> Register(Schools Schools)
        {
            var SchoolsWithSameName = _dbContext.Schools.SingleOrDefault(u => u.SchoolName == Schools.SchoolName);

            if (SchoolsWithSameName != null)
            {
                return(BadRequest("School with this name already exists"));
            }
            var SchoolsObj = new Schools
            {
                SchoolID        = Guid.NewGuid(),
                Active          = Schools.Active,
                Address         = Schools.Address,
                CityID          = Schools.CityID,
                EmailID         = Schools.EmailID,
                LocationMAP     = Schools.LocationMAP,
                NoofSubscribers = Schools.NoofSubscribers,
                Phone1          = Schools.Phone1,
                Phone2          = Schools.Phone2,
                RegionID        = Schools.RegionID,
                SchoolName      = Schools.SchoolName
            };

            _dbContext.Schools.Add(SchoolsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#8
0
        public async Task <IActionResult> Register(ADMINMast ADMINMast)
        {
            var userWithSameEmail = _dbContext.ADMINMast.SingleOrDefault(u => u.EmailID == ADMINMast.EmailID);

            if (userWithSameEmail != null)
            {
                return(BadRequest("User with this email already exists"));
            }
            var ADMINMastObj = new ADMINMast
            {
                AdminID     = Guid.NewGuid(),
                Name        = ADMINMast.Name,
                UserName    = ADMINMast.UserName,
                Password    = ADMINMast.Password,
                EmailID     = ADMINMast.EmailID,
                CityID      = ADMINMast.CityID,
                Accesslevel = ADMINMast.Accesslevel,
                Active      = ADMINMast.Active
            };

            _dbContext.ADMINMast.Add(ADMINMastObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#9
0
        public async Task <IActionResult> Register(UserSubscriptions UserSubscriptions)
        {
            //var userWithSameEmail = _dbContext.ADMINMast.SingleOrDefault(u => u.EmailID == ADMINMast.EmailID);
            //if (userWithSameEmail != null) return BadRequest("User with this email already exists");
            var UserSubscriptionsObj = new UserSubscriptions
            {
                UserSubscriptionID    = Guid.NewGuid(),
                DiscountApplied       = UserSubscriptions.DiscountApplied,
                FamMembID             = UserSubscriptions.FamMembID,
                ItemAddOnQty          = UserSubscriptions.ItemAddOnQty,
                ItemID                = UserSubscriptions.ItemID,
                OfferID               = UserSubscriptions.OfferID,
                Quantity              = UserSubscriptions.Quantity,
                ScheduledDates        = UserSubscriptions.ScheduledDates,
                ScheduledTime         = UserSubscriptions.ScheduledTime,
                SubSchID              = UserSubscriptions.SubSchID,
                SubscriptionEndDate   = UserSubscriptions.SubscriptionEndDate,
                SubscriptionPrice     = UserSubscriptions.SubscriptionPrice,
                SubscriptionStartDate = UserSubscriptions.SubscriptionStartDate,
                userId                = UserSubscriptions.userId
            };

            _dbContext.UserSubscriptions.Add(UserSubscriptionsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
        public async Task <IActionResult> Register(FamilyMemberDetails FamilyMemberDetails)
        {
            var userWithSameEmail = _dbContext.FamilyMemberDetails.SingleOrDefault(u => u.MembEmail == FamilyMemberDetails.MembEmail);

            if (userWithSameEmail != null)
            {
                return(BadRequest("User with this email already exists"));
            }
            var FamilyMemberDetailsObj = new FamilyMemberDetails
            {
                FamMembID     = Guid.NewGuid(),
                MembType      = FamilyMemberDetails.MembType,
                userId        = FamilyMemberDetails.userId,
                MembFName     = FamilyMemberDetails.MembFName,
                MembLName     = FamilyMemberDetails.MembLName,
                MembEmail     = FamilyMemberDetails.MembEmail,
                MembPhone1    = FamilyMemberDetails.MembPhone1,
                MembPhone2    = FamilyMemberDetails.MembPhone2,
                MembBirthDate = FamilyMemberDetails.MembBirthDate,
                MembAge       = FamilyMemberDetails.MembAge,
                ModeType      = FamilyMemberDetails.ModeType,
                SchoolID      = FamilyMemberDetails.SchoolID,
                OfficeID      = FamilyMemberDetails.OfficeID,
                Standard      = FamilyMemberDetails.Standard,
                Division      = FamilyMemberDetails.Division
            };

            _dbContext.FamilyMemberDetails.Add(FamilyMemberDetailsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#11
0
        public async Task <IActionResult> Register(Offers Offers)
        {
            var OfferWithSameName = _dbContext.Offers.SingleOrDefault(u => u.OfferName == Offers.OfferName);

            if (OfferWithSameName != null)
            {
                return(BadRequest("Offer with this name already exists"));
            }
            var OffersObj = new Offers
            {
                OfferID          = Guid.NewGuid(),
                Active           = Offers.Active,
                ItemID           = Offers.ItemID,
                OfferCode        = Offers.OfferCode,
                OfferDescription = Offers.OfferDescription,
                OfferName        = Offers.OfferName,
                Offertype        = Offers.Offertype,
                Price            = Offers.Price
            };

            _dbContext.Offers.Add(OffersObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#12
0
        public async Task <IActionResult> Register(DeliveryBoys DeliveryBoy)
        {
            var userWithSameEmail = _dbContext.DeliveryBoys.SingleOrDefault(u => u.DBEmail == DeliveryBoy.DBEmail);

            if (userWithSameEmail != null)
            {
                return(BadRequest("User with this email already exists"));
            }
            var DeliveryBoyObj = new DeliveryBoys
            {
                DeliveryBoyID = Guid.NewGuid(),
                DBFName       = DeliveryBoy.DBFName,
                DBLName       = DeliveryBoy.DBLName,
                DBUserName    = DeliveryBoy.DBUserName,
                DBPassword    = DeliveryBoy.DBPassword,
                DBAddress     = DeliveryBoy.DBAddress,
                DBEmail       = DeliveryBoy.DBEmail,
                DBPhone1      = DeliveryBoy.DBPhone1,
                DBPhone2      = DeliveryBoy.DBPhone2,
                DBCityID      = DeliveryBoy.DBCityID,
                DBRegionID    = DeliveryBoy.DBRegionID,
                LicenseNo     = DeliveryBoy.LicenseNo,
                VehicleID     = DeliveryBoy.VehicleID
            };

            _dbContext.DeliveryBoys.Add(DeliveryBoyObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
        public async Task <IActionResult> Register(AppInstallations AppInstallations)
        {
            var userWithSameEmail = _dbContext.AppInstallations.SingleOrDefault(u => u.userId == AppInstallations.userId && u.DeviceID == AppInstallations.DeviceID);

            if (userWithSameEmail != null)
            {
                var AppInstallation = _dbContext.AppInstallations.Where(s => s.AppInstId == userWithSameEmail.AppInstId);
                _dbContext.AppInstallations.RemoveRange(AppInstallations);
                _dbContext.SaveChanges();
            }
            var AppInstallationsObj = new AppInstallations
            {
                AppInstId       = Guid.NewGuid(),
                userId          = AppInstallations.userId,
                DeviceID        = AppInstallations.DeviceID,
                DeviceOS        = AppInstallations.DeviceOS,
                DeviceOSVersion = AppInstallations.DeviceOSVersion,
                DeviceModel     = AppInstallations.DeviceModel,
                DeviceNickName  = AppInstallations.DeviceNickName,
                InstallDate     = AppInstallations.InstallDate,
                InstallType     = AppInstallations.InstallType,
                LastAuthDate    = AppInstallations.LastAuthDate,
                AppVersion      = AppInstallations.AppVersion,
                RegId           = AppInstallations.RegId,
                MasterSyncReq   = AppInstallations.MasterSyncReq,
                InstStatus      = AppInstallations.InstStatus
            };

            _dbContext.AppInstallations.Add(AppInstallationsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#14
0
        public async Task <ActionResult <Product> > Post([FromBody] Product product)
        {
            db.Products.Add(product);
            await db.SaveChangesAsync();

            return(product);
        }
示例#15
0
        public async Task <ActionResult <OrderLine> > Post([FromBody] OrderLine OrderLines)
        {
            db.OrderLines.Add(OrderLines);
            await db.SaveChangesAsync();

            return(OrderLines);
        }
示例#16
0
        public async Task <IActionResult> Register(Offices Offices)
        {
            var userWithSameEmail = _dbContext.Offices.SingleOrDefault(u => u.EmailID == Offices.EmailID);

            if (userWithSameEmail != null)
            {
                return(BadRequest("User with this email already exists"));
            }
            var OfficesObj = new Offices
            {
                OfficeID        = Guid.NewGuid(),
                OfficeName      = Offices.OfficeName,
                Address         = Offices.Address,
                LocationMAP     = Offices.LocationMAP,
                EmailID         = Offices.EmailID,
                Phone1          = Offices.Phone1,
                Phone2          = Offices.Phone2,
                CityID          = Offices.CityID,
                RegionID        = Offices.RegionID,
                NoofSubscribers = Offices.NoofSubscribers,
                Active          = "y"
            };

            _dbContext.Offices.Add(OfficesObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#17
0
        public async Task Initialize(FoodDbContext context)
        {
            context.FoodItems.Add(new FoodItem()
            {
                Calories = 2000, Name = "pie", Weight = 100, Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodItem()
            {
                Calories = 1000, Name = "Lasagne", Weight = 50, Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodItem()
            {
                Calories = 1100, Name = "Hamburger", Weight = 60, Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodItem()
            {
                Calories = 1200, Name = "Spaghetti", Weight = 75, Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodItem()
            {
                Calories = 1300, Name = "Pizza", Weight = 80, Created = DateTime.Now
            });

            await context.SaveChangesAsync();
        }
示例#18
0
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }

            try
            {
                await _repositoryFoodDbContext.AddAsync(entity);

                await _repositoryFoodDbContext.SaveChangesAsync();

                return(entity);
            }
            catch (Exception)
            {
                throw new Exception($"{nameof(entity)} could not be saved");
            }
        }
示例#19
0
        public async Task <IActionResult> Register(User user)
        {
            var userWithSameEmail = _dbContext.Users.SingleOrDefault(u => u.Email == user.Email);

            if (userWithSameEmail != null)
            {
                return(BadRequest("User with this email already exists"));
            }
            var userObj = new User
            {
                Name     = user.Name,
                Email    = user.Email,
                Password = SecurePasswordHasherHelper.Hash(user.Password),
                Role     = "User"
            };

            _dbContext.Users.Add(userObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#20
0
        public async Task <IActionResult> Register(ItemAddOns ItemAddOns)
        {
            var ItemAddOnsObj = new ItemAddOns
            {
                ItemAddOnID = Guid.NewGuid(),
                AddOnName   = ItemAddOns.AddOnName,
                AddOnPrice  = ItemAddOns.AddOnPrice
            };

            _dbContext.ItemAddOns.Add(ItemAddOnsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#21
0
        public async Task <IActionResult> Register(ItemTypes ItemTypes)
        {
            var sameItemType = _dbContext.ItemTypes.SingleOrDefault(u => u.ItemType == ItemTypes.ItemType);

            if (sameItemType != null)
            {
                return(BadRequest("Item type already exists."));
            }
            var ItemTypesObj = new ItemTypes
            {
                ItemTypeID = Guid.NewGuid(),
                ItemType   = ItemTypes.ItemType
            };

            _dbContext.ItemTypes.Add(ItemTypesObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#22
0
        public async Task <IActionResult> Register(VendorItems VendorItems)
        {
            //var userWithSameEmail = _dbContext.ADMINMast.SingleOrDefault(u => u.EmailID == ADMINMast.EmailID);
            //if (userWithSameEmail != null) return BadRequest("User with this email already exists");
            var VendorItemsObj = new VendorItems
            {
                vendorItemID       = Guid.NewGuid(),
                Capacity           = VendorItems.Capacity,
                ItemID             = VendorItems.ItemID,
                PerPlateRate       = VendorItems.PerPlateRate,
                PreferentialRating = VendorItems.PreferentialRating,
                VendorId           = VendorItems.VendorId
            };

            _dbContext.VendorItems.Add(VendorItemsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#23
0
        public async Task <IActionResult> Register(ModeTypes ModeTypes)
        {
            var userWithSameEmail = _dbContext.ModeTypes.SingleOrDefault(u => u.ModeType == ModeTypes.ModeType);

            if (userWithSameEmail != null)
            {
                return(BadRequest("ModeType already exists"));
            }
            var ModeTypesObj = new ModeTypes
            {
                ModeType = ModeTypes.ModeType,
                ModeName = ModeTypes.ModeName
            };

            _dbContext.ModeTypes.Add(ModeTypesObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#24
0
        public async Task <IActionResult> Register(SubscriptionSchedule SubscriptionSchedule)
        {
            var userWithSameEmail = _dbContext.SubscriptionSchedule.SingleOrDefault(u => u.ScheduleName == SubscriptionSchedule.ScheduleName);

            if (userWithSameEmail != null)
            {
                return(BadRequest("Schedule Name already exists"));
            }
            var SubscriptionScheduleObj = new SubscriptionSchedule
            {
                SubSchID     = Guid.NewGuid(),
                ScheduleType = SubscriptionSchedule.ScheduleType,
                ScheduleName = SubscriptionSchedule.ScheduleName
            };

            _dbContext.SubscriptionSchedule.Add(SubscriptionScheduleObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#25
0
        public async Task <IActionResult> Register(AdminRegions AdminRegions)
        {
            var AdminWithSameRegion = _dbContext.AdminRegions.SingleOrDefault(u => u.RegionID == AdminRegions.RegionID);

            if (AdminWithSameRegion != null)
            {
                return(BadRequest("Admin with this region already exists"));
            }
            var AdminRegionsObj = new AdminRegions
            {
                AdminRegionID = Guid.NewGuid(),
                AdminID       = AdminRegions.AdminID,
                RegionID      = AdminRegions.RegionID
            };

            _dbContext.AdminRegions.Add(AdminRegionsObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
        public async Task <List <ComboProduct> > AddComboProductRangeAsync(List <ComboProduct> comboProducts)
        {
            if (!comboProducts.Any())
            {
                throw new ArgumentNullException($"{nameof(AddComboProductRangeAsync)} entity must not be null");
            }

            try
            {
                await _context.AddRangeAsync(comboProducts);

                await _context.SaveChangesAsync();

                return(comboProducts);
            }
            catch (Exception)
            {
                throw new Exception($"{nameof(comboProducts)} could not be saved");
            }
        }
示例#27
0
        public async Task <IActionResult> Register(City City)
        {
            var CityWithSameName = _dbContext.City.SingleOrDefault(u => u.CityID == City.CityID);

            if (CityWithSameName != null)
            {
                return(BadRequest("City with this name already exists"));
            }
            var CityObj = new City
            {
                CityID   = Guid.NewGuid(),
                CityCode = City.CityCode,
                CityName = City.CityName,
                Active   = City.Active
            };

            _dbContext.City.Add(CityObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
示例#28
0
        public async Task Initialize(FoodDbContext context)
        {
            context.FoodItems.Add(new FoodEntity()
            {
                Calories = 1000, Type = "Starter", Name = "Lasagne", Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodEntity()
            {
                Calories = 1100, Type = "Main", Name = "Hamburger", Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodEntity()
            {
                Calories = 1200, Type = "Dessert", Name = "Spaghetti", Created = DateTime.Now
            });
            context.FoodItems.Add(new FoodEntity()
            {
                Calories = 1300, Type = "Starter", Name = "Pizza", Created = DateTime.Now
            });

            await context.SaveChangesAsync();
        }
示例#29
0
        public async Task <IActionResult> Register(Users user)
        {
            try
            {
                var userWithSameEmail = _dbContext.Users.SingleOrDefault(u => u.Email == user.Email);
                if (userWithSameEmail != null)
                {
                    return(BadRequest("User with this email already exists"));
                }
                var userObj = new Users
                {
                    userId         = Guid.NewGuid(),
                    Username       = user.Username,
                    Password       = user.Password,
                    FName          = user.FName,
                    LName          = user.LName,
                    Email          = user.Email,
                    Phone1         = user.Phone1,
                    Phone2         = user.Phone2,
                    Address        = user.Address,
                    LocationMAP    = "",
                    Gender         = user.Gender,
                    BirthDate      = user.BirthDate,
                    Age            = user.Age,
                    DateRegistered = user.DateRegistered,
                    CityID         = user.CityID,
                    RegionID       = user.RegionID,
                    Active         = user.Active
                };
                _dbContext.Users.Add(userObj);
                await _dbContext.SaveChangesAsync();

                return(StatusCode(StatusCodes.Status201Created));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status201Created));
            }
        }
示例#30
0
        public async Task <IActionResult> Register(Region Region)
        {
            var RegionWithSameName = _dbContext.Region.SingleOrDefault(u => u.RegionID == Region.RegionID);

            if (RegionWithSameName != null)
            {
                return(BadRequest("Region with this name already exists"));
            }
            var RegionObj = new Region
            {
                RegionID   = Guid.NewGuid(),
                Active     = Region.Active,
                CityID     = Region.CityID,
                Pincode    = Region.Pincode,
                RegionName = Region.RegionName
            };

            _dbContext.Region.Add(RegionObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }