コード例 #1
0
ファイル: MyBusiness.cs プロジェクト: JFPenguin/CookTime
        /// <summary>
        /// This method is in charge of retrieving the result of the Picture dialog fragment.
        /// </summary>
        /// <param name="sender"> Reference to the object that raised the event </param>
        /// <param name="e"> Contains the event data </param>
        private void PictureAction(object sender, PicEvent e)
        {
            using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" };
            var response = e.Message;

            if (response == 0)
            {
                // do this code when the user chose to see the logo
                if (!string.IsNullOrEmpty(bsns.photo))
                {
                    var transaction = SupportFragmentManager.BeginTransaction();
                    var dialogPShow = new DialogPShow();

                    dialogPShow.Url      = logoUrl;
                    dialogPShow.TypeText = "Business logo";
                    dialogPShow.Show(transaction, "bsns");
                }
                else
                {
                    // happens when the user has no image so we must display default.
                    string toastText = "you have not set a logo yet. To view one, you must first set it up.";
                    _toast = Toast.MakeText(this, toastText, ToastLength.Short);
                    _toast.Show();
                }
            }
            else
            {
                // do this code when the user chose to change their image.
                Intent gallery = new Intent();
                gallery.SetType("image/*");
                gallery.SetAction(Intent.ActionGetContent);
                StartActivityForResult(Intent.CreateChooser(gallery, "select a logo"), 0);
            }
        }
コード例 #2
0
        public IActionResult Create_Event_Entry(PicEvent e)
        {
            string uniqueFileName = null;

            if (e.e_photo != null)
            {
                string uploadsFOlder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                //global unique identifier
                uniqueFileName = Guid.NewGuid().ToString() + "_" + e.e_photo.FileName;
                string filePath = Path.Combine(uploadsFOlder, uniqueFileName);
                e.e_photo.CopyTo(new FileStream(filePath, FileMode.Create));
            }

            var fr = JsonConvert.DeserializeObject <Fundraiser>(HttpContext.Session.GetString("FundraiserSession"));


            string        connection_string = configuration.GetConnectionString("DefaultConnectionString");
            SqlConnection connection        = new SqlConnection(connection_string);

            connection.Open();
            ////string query = "SELECT [f_id],[f_name],[f_email],[f_password],[f_phone],[f_about],[f_category] FROM [dbo].[FUNDRAISERS]"

            //event pic is neglected for the time being
            string     query = "INSERT INTO [dbo].[EVENT] ([e_title],[e_location],[e_opening_date],[e_closing_date],[e_exp_amount],[e_pic],[e_raised_amount],[e_donor_count],[e_state],[e_details],[f_id],[e_category],[e_trans],[e_half_fund],[e_full_fund],[e_posted],[e_halted],[e_success],[e_expired]) VALUES (@title,@location,@o_date,@c_date,@exp,@pic,0,0,0,@details,@f_id, @category, @trans, 0, 0, 0, 0, 0, 0)";
            SqlCommand com   = new SqlCommand(query, connection);

            com.Parameters.AddWithValue("@title", e.e_title);
            com.Parameters.AddWithValue("@location", e.e_location);
            com.Parameters.AddWithValue("@o_date", e.e_opening_date);
            com.Parameters.AddWithValue("@c_date", e.e_closing_date);
            com.Parameters.AddWithValue("@exp", e.e_exp_amount);
            //com.Parameters.AddWithValue("@raised", e.e_raised_amount);
            //com.Parameters.AddWithValue("@count", e.e_donor_count);
            com.Parameters.AddWithValue("@pic", uniqueFileName.ToString());
            //com.Parameters.AddWithValue("@state", e.e_state);
            com.Parameters.AddWithValue("@details", e.e_details);
            com.Parameters.AddWithValue("@f_id", fr.f_id);
            com.Parameters.AddWithValue("@category", e.e_category);
            com.Parameters.AddWithValue("@trans", e.e_trans);

            ViewBag.f_id = fr.f_id;

            com.ExecuteNonQuery();
            //ViewData["e_key"] = uniqueFileName.ToString();
            connection.Close();
            return(RedirectToAction("fundraiser_index", "Fundraiser", new { id = fr.f_id }));
            //return View(e);
        }