internal async Task <RestaurantEntity> Create(RestaurantEntity entity) { entity.PopulateSearchTag(entity); await context.Restaurants.InsertOneAsync(entity); return(entity); }
public HttpResponseMessage BookOrderDetail(RestaurantEntity _Table) { HttpResponseMessage response; List <RestaurantEntity> userData = new List <RestaurantEntity>(); try { if (_Table == null) { response = Request.CreateResponse(HttpStatusCode.PreconditionFailed, "tablenumber can not be blank!"); } else { // check for null paramter //get data from database userData = RegistrationProcCall.usp_user_restaurantBookedOrderDetail(_Table); response = Request.CreateResponse(HttpStatusCode.OK, userData); } } catch { response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Server error occured while processing request"); } return(response); }
public static RestaurantEntity usp_user_restaurantquantityUpdate(RestaurantquantityUpdate _Update) { RestaurantEntity _ListEntity = new RestaurantEntity(); using (var connection = SQLConnection.GetOpenSQLConnection()) { // string sqlQuery = "usp_user_restaurantquantityUpdate @id,@quantity"; // _ListEntity = connection.Query<RestaurantEntity>(sqlQuery, new { id = _Update.id, quantity = _Update.quantity, }).FirstOrDefault(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_user_restaurantquantityUpdate"; cmd.Parameters.Add("@id", SqlDbType.Int).Value = _Update.id; cmd.Parameters.Add("@quantity", SqlDbType.VarChar).Value = _Update.quantity; // cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = _Update.name; // cmd.Parameters.Add("@contactnumber", SqlDbType.Int).Value = _Update.contactnumber; // cmd.Parameters.Add("@email", SqlDbType.VarChar).Value = _Update.email; //cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = _Update.password; //cmd.Parameters.Add("@fathername", SqlDbType.VarChar).Value = _Update.fathername; //cmd.Parameters.Add("@addharnumber", SqlDbType.Int).Value = _Update.addharnumber; //cmd.Parameters.Add("@pannumber", SqlDbType.VarChar).Value = _Update.pannumber; //cmd.Parameters.Add("@selectRole", SqlDbType.VarChar).Value = _Update.selectRole; cmd.Connection = connection; _ListEntity = (RestaurantEntity)cmd.ExecuteScalar(); } return(_ListEntity); }
public void AddRestaurant(RestaurantRequestDto requestDto) { RestaurantEntity toAdd = new RestaurantEntity { Name = requestDto.Name, Address = requestDto.Address, FamilyFriendly = requestDto.FamilyFriendly, VeganOptions = requestDto.VeganOptions, Rating = requestDto.Rating }; _restaurantRepository.Add(toAdd); foreach (int id in requestDto.CuisineTagIds) { _restaurantRepository.AddCuisineTag(new RestaurantCuisineEntity { CuisineId = id, RestaurantId = toAdd.Id }); } if (!_restaurantRepository.Save()) { throw new Exception("Creating a item failed on save."); } }
protected override void InitializeStorage(IFoodOrderingContextFactory factory, int count) { using (var context = factory.Create()) { var restaurant = new RestaurantEntity() { Name = "testRestaurant" }; var insertedRestauran = context.Restaurant.Add(restaurant).Entity; var dailyMenu = new DailyMenuEntity() { RestaurantId = insertedRestauran.Id }; var foods = Enumerable.Range(1, count).Select(x => new FoodEntity() { Id = x, Name = $"Name {x}", RestaurantId = insertedRestauran.Id }); context.Food.AddRange(foods); context.SaveChanges(); } }
public async Task UpdateRestaurant(RestaurantEntity restaurant) { var entry = context.Entry(restaurant); entry.State = EntityState.Modified; await context.SaveChangesAsync(); }
public bool UpdateRestaurant(int restaurantId, RestaurantEntity restaurantEntity) { var success = false; if (restaurantEntity != null) { using (var scope = new TransactionScope()) { var restaurant = _unitOfWork.RestaurantRepository.GetByID(restaurantId); if (restaurant != null) { restaurant.Name = restaurantEntity.Name; restaurant.StreetAddress1 = restaurantEntity.StreetAddress1; restaurant.StreetAddress2 = restaurantEntity.StreetAddress2; restaurant.City = restaurantEntity.City; restaurant.State = restaurantEntity.State; restaurant.Zip = restaurantEntity.Zip; restaurant.Type = restaurantEntity.RestaurantType.Id; restaurant.Deleted = restaurantEntity.Deleted; _unitOfWork.RestaurantRepository.Update(restaurant); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
public void UpdateRestaurant(RestaurantEntity entity) { RestaurantEntity restaurantEntity = GetRestaurant(entity.RestaurantName); restaurantEntity.RestaurantName = entity.RestaurantName; restaurantEntity.Location = entity.Location; }
public void UpdateDish(int restaurantId, int dishId, IDish dish) { RestaurantEntity restaurantEntity = _dbContext .Restaurants .Include(r => r.Dishes) .FirstOrDefault(r => r.Id == restaurantId); if (restaurantEntity is null) { throw new NotFoundException("Restaurant not found."); } DishEntity dishEntity = restaurantEntity .Dishes .FirstOrDefault(d => d.Id == dishId); if (dishEntity is null) { throw new NotFoundException("Dish not found."); } dishEntity = _mapper.Map(dish, dishEntity); _dbContext.Dishes.Update(dishEntity); _dbContext.SaveChanges(); }
static RestaurantRepositary() { RestaurantEntity restaurantEntity = new RestaurantEntity("Chennise", "Indian", "Sarada college,Salem"); restaurantEntities.Add(restaurantEntity); restaurantEntity = new RestaurantEntity("Taj", "Chinese", "Bus-Stand,Erode"); restaurantEntities.Add(restaurantEntity); }
public static void Update(RestaurantEntity restaurant) { RestaurantEntity updatedRestaurant = RestaurantDetails.Find(res => res.Id == restaurant.Id); updatedRestaurant.Id = restaurant.Id; updatedRestaurant.Name = restaurant.Name; updatedRestaurant.Description = restaurant.Description; }
public async Task <RestaurantEntity> CreateRestaurant(RestaurantEntity restaurant) { var createdRestaurant = await context.Restaurants.AddAsync(restaurant); await context.SaveChangesAsync(); return(createdRestaurant.Entity); }
public void DeleteRestaurant(string restaurantName) { RestaurantEntity restaurant = GetRestaurant(restaurantName); if (restaurant != null) { restaurantEntities.Remove(restaurant); } }
public async Task <ReplaceOneResult> Update(RestaurantEntity restaurant) { var filter = Builders <RestaurantEntity> .Filter.Where(x => x._id == restaurant._id); restaurant.PopulateSearchTag(restaurant); var updatedRestaurant = await context.Restaurants.ReplaceOneAsync(filter, restaurant); return(updatedRestaurant); }
protected override void OnListItemClick(ListView l, View v, int position, long id) { RestaurantEntity restaurant = restaurantsModel[position]; Intent restaurantEdit = new Intent(this, typeof(RestaurantViewActivity)); restaurantEdit.PutExtra("restaurantID", restaurant.Id); StartActivity(restaurantEdit); }
public static void Delete(int resId) { RestaurantEntity restaurant = GetRestaurantById(resId); if (restaurant != null) { RestaurantDetails.Remove(restaurant); } }
static RestaurantRepository() { RestaurantEntity restaurant; restaurant = new RestaurantEntity(1, "YumPlum", "Yumplum cake factory"); RestaurantDetails.Add(restaurant); restaurant = new RestaurantEntity(2, "SpiceKing", "SpiceKing is the King of Spices"); RestaurantDetails.Add(restaurant); }
public static Restaurant ToModel(this RestaurantEntity entity) { return(new Restaurant { Id = entity.Id, Name = entity.Name, Address = entity.Address }); }
public ActionResult Create_Post() { RestaurantEntity restaurant = new RestaurantEntity(); UpdateModel(restaurant); RestaurantRepository.Add(restaurant); TempData["Message"] = "Added Succesfully"; return(RedirectToAction("Index")); }
public IHttpActionResult GetByID(GetRestaurantByIDRequest request) { RestaurantEntity restaurantEntity = db.RestaurantEntities.Find(request.ID); if (restaurantEntity == null) { return(NotFound()); } return(Ok(restaurantEntity)); }
public static RestaurantEntity usp_user_restaurantgestDetail(TableModel _EntiyID) { RestaurantEntity _ListingEntity = new RestaurantEntity(); using (var connection = SQLConnection.GetOpenSQLConnection()) { string sqlQuery = "usp_user_restaurantgestDetail @id"; _ListingEntity = connection.Query <RestaurantEntity>(sqlQuery, new { id = _EntiyID.id }).FirstOrDefault(); } return(_ListingEntity); }
public bool UpdateRestaurant(RestaurantEntity restaurant) { /*var res = dbContext.Restaurants.FirstOrDefault(r => r.Id == restaurant.Id); * res.Name = restaurant.Name ?? res.Name; * res.Phone = restaurant.Phone ?? res.Phone; * res.Address = restaurant.Address ?? res.Address; * res.Fundation = restaurant.Fundation ?? res.Fundation;*/ dbContext.Restaurants.Update(restaurant); return(true); }
public static List <RestaurantEntity> usp_user_restaurantBookedOrderDetail(RestaurantEntity _Table) { List <RestaurantEntity> _UserEntity = new List <RestaurantEntity>(); using (var connection = SQLConnection.GetOpenSQLConnection()) { string sqlQuery = "usp_user_restaurantBookedOrderDetail @tablenumber"; _UserEntity = connection.Query <RestaurantEntity>(sqlQuery, new { tablenumber = _Table.tablenumber }).ToList <RestaurantEntity>(); } return(_UserEntity); }
private void InCreaseKarmaForTheRestraunt(RestaurantEntity restaurantEntity) { if (restaurantEntity == null) { return; } try { Console.WriteLine("Increasing Karma on the BlockChain"); string ALGOD_API_ADDR = "http://hackathon.algodev.network:9100"; string ALGOD_API_TOKEN = "ef920e2e7e002953f4b29a8af720efe8e4ecc75ff102b165e0472834b25832c1"; //find in the algod.token var algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); var transParams = algodApiInstance.TransactionParams(); ulong?feePerByte = transParams.Fee; var genesisHash = new Digest(Convert.FromBase64String(transParams.Genesishashb64)); var genesisID = transParams.GenesisID; var s = algodApiInstance.GetStatus(); var firstRound = s.LastRound; Console.WriteLine("Current Round: " + firstRound); ulong? amount = 100000; ulong? lastRound = firstRound + 1000; // 1000 is the max tx window string SRC_ACCOUNT = "typical permit hurdle hat song detail cattle merge oxygen crowd arctic cargo smooth fly rice vacuum lounge yard frown predict west wife latin absent cup"; Account src = new Account(SRC_ACCOUNT); Transaction tx = new Transaction(src.Address, new Address(restaurantEntity.AlgorandAddress), amount, firstRound, lastRound, genesisID, genesisHash); SignedTransaction signedTx = src.SignTransactionWithFeePerByte(tx, feePerByte.Value); //encode to msg-pack var encodedMsg = Algorand.Encoder.EncodeToMsgPack(signedTx); var id = algodApiInstance.RawTransaction(encodedMsg); Console.WriteLine("Successfully sent tx with id: " + id.TxId); } catch (Exception e) { // This is generally expected, but should give us an informative error message. Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message); } try { Console.WriteLine("Increasing Karma on The DB"); restaurantEntity.KarmaScore++; _gretaFoodDb.SaveChanges(); } catch (Exception e) { Console.WriteLine("Was not manage to increase karma in the DB"); } }
public IHttpActionResult DeleteByID(RestaurantDeleteModel entity) { RestaurantEntity restaurantEntity = db.RestaurantEntities.Find(entity.ID); if (restaurantEntity == null) { return(BadRequest(ModelState)); } db.RestaurantEntities.Remove(restaurantEntity); db.SaveChanges(); return(Ok()); }
public void DeleteRestaurant(int id) { RestaurantEntity entity = _dbContext .Restaurants .FirstOrDefault(r => r.Id == id); if (entity is null) { throw new NotFoundException("Restaurant not found."); } _dbContext.Restaurants.Remove(entity); _dbContext.SaveChanges(); }
public IRestaurant GetById(int id) { RestaurantEntity entity = _dbContext .Restaurants .Include(a => a.Address) .FirstOrDefault(r => r.Id == id); if (entity is null) { throw new NotFoundException("Restaurant not found."); } return(_mapper.Map <Restaurant>(entity)); }
public List <RestaurantEntity> GetRestaurantEntityList(RestaurantEntity condition_entity) { GenericWhereEntity <RestaurantEntity> where_entity = new GenericWhereEntity <RestaurantEntity>(); if (condition_entity.RESTAURANT_ID != null) { where_entity.Where(n => (n.RESTAURANT_ID == condition_entity.RESTAURANT_ID)); } if (condition_entity.RESTAURANT_NAME != null) { where_entity.Where(n => (n.RESTAURANT_NAME == condition_entity.RESTAURANT_NAME)); } return(EntityExecution.SelectAll(where_entity)); }
public async Task <bool> Insert(Restaurant restaurant) { RestaurantEntity entity = _mapper.Map <RestaurantEntity>(restaurant); try { await _context.Restaurants.InsertOneAsync(entity); } catch { return(false); } return(true); }
public void UpdateRestaurant(int id, IRestaurant restaurant) { RestaurantEntity entity = _dbContext .Restaurants .Include(e => e.Address) .FirstOrDefault(r => r.Id == id); if (entity is null) { throw new NotFoundException("Restaurant not found."); } entity = _mapper.Map(restaurant, entity); _dbContext.Restaurants.Update(entity); _dbContext.SaveChanges(); }