Exemplo n.º 1
0
        public bool SaveBakeryOrder(BakeryOrderModel order)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(addOrderBakery_SQL, conn);
                    cmd.Parameters.AddWithValue("@orderName", order.OrderName);
                    cmd.Parameters.AddWithValue("@phoneNumber", order.PhoneNumber);
                    cmd.Parameters.AddWithValue("@pickUpTime", order.PickupTime);
                    cmd.Parameters.AddWithValue("@userInfoId", order.UserInfoId);
                    cmd.Parameters.AddWithValue("@size", order.Size);
                    cmd.Parameters.AddWithValue("@dough", order.Dough);
                    cmd.Parameters.AddWithValue("@icing", order.Icing);
                    cmd.Parameters.AddWithValue("@messageInfo", order.MessageInfo);
                    cmd.Parameters.AddWithValue("@borderTrim", order.BorderTrim);
                    cmd.Parameters.AddWithValue("@kitNumber", order.KitNumber);
                    cmd.Parameters.AddWithValue("@kitName", order.Kitname);
                    cmd.Parameters.AddWithValue("@storeId", order.StoreId);

                    int rowsAffected = cmd.ExecuteNonQuery();
                    return(rowsAffected > 0);
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public ActionResult BakeryOrder(BakeryOrderModel order)
        {
            if (order.Kitname == null)
            {
                order.Kitname = "n/a";
            }

            OrdersDAL dal = new OrdersDAL();

            if (dal.SaveBakeryOrder(order))
            {
                return(RedirectToAction("Orders"));
            }
            else
            {
                return(View("BakeryOrder", order));
            }
        }
Exemplo n.º 3
0
        public List <BakeryOrderModel> GetAllBakeryOrdersForStore(int storeId)
        {
            List <BakeryOrderModel> output = new List <BakeryOrderModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(getBakeryOrdersForStore_SQL, conn);
                    cmd.Parameters.AddWithValue("@storeId", storeId);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        BakeryOrderModel order = new BakeryOrderModel();

                        order.BorderTrim  = Convert.ToString(reader["borderTrim"]);
                        order.Dough       = Convert.ToString(reader["dough"]);
                        order.Icing       = Convert.ToString(reader["icing"]);
                        order.Id          = Convert.ToInt32(reader["id"]);
                        order.IsActive    = Convert.ToBoolean(reader["isActive"]);
                        order.Kitname     = Convert.ToString(reader["kitName"]);
                        order.KitNumber   = Convert.ToInt32(reader["kitNumber"]);
                        order.MessageInfo = Convert.ToString(reader["messageInfo"]);
                        order.PhoneNumber = Convert.ToString(reader["phoneNumber"]);
                        order.OrderName   = Convert.ToString(reader["orderName"]);
                        order.OrderTime   = Convert.ToDateTime(reader["orderTime"]);
                        order.PickupTime  = Convert.ToDateTime(reader["pickUpTime"]);
                        order.Size        = Convert.ToString(reader["size"]);
                        order.StoreId     = Convert.ToInt32(reader["storeId"]);
                        order.UserInfoId  = Convert.ToInt32(reader["userInfoId"]);

                        output.Add(order);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return(output);
        }
Exemplo n.º 4
0
        public ActionResult BakeryOrder()
        {
            BakeryOrderModel model = new BakeryOrderModel();

            return(View("BakeryOrder", model));
        }