示例#1
0
        public IActionResult BillsAdd(BillsAdd model, int id)
        {
            tableCoffeeId = id;
            model.TableID = id;
            var            result         = 0;
            var            url            = "https://localhost:44354/api/bills/add";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(model);
                streamWriter.Write(json);
            }
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var resResult = streamReader.ReadToEnd();
                result = int.Parse(resResult);
            }
            if (result > 0)
            {
                return(RedirectToAction("GetById", "Bills", new { Id = result }));
            }
            else
            {
                return(RedirectToAction("Index", "TableCoffees"));
            }
        }
 public int BillsAdd(BillsAdd billsAdd)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@TableID", billsAdd.TableID);
         var result = SqlMapper.ExecuteScalar <int> (con, "Bills_Add", param: parameters, commandType: CommandType.StoredProcedure);
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
0
 public int BillsAdd(BillsAdd billsAdd)
 {
     return(_billsService.BillsAdd(billsAdd));
 }
 public int BillsAdd(BillsAdd billsAdd)
 {
     return(_billsRepository.BillsAdd(billsAdd));
 }