示例#1
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (txtID.Text == "")
     {
         MessageBox.Show("Choose Compliment");
     }
     else
     {
         DialogResult dr = MessageBox.Show("Do you want delete this Compliment?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (DialogResult.Yes == dr)
         {
             try
             {
                 Compliment tg = new Compliment();
                 int        id = Convert.ToInt32(txtID.Text);
                 tg = context.Compliments.Where(p => p.ID == id).FirstOrDefault();
                 context.Compliments.Remove(tg);
                 context.SaveChanges();
                 MessageBox.Show("Deleted");
                 LoaddgvCompliment();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
        public void ComplimentMessage(ComplimentType type)
        {
            this.Dispatcher.Invoke(() =>
            {
                Canvas activeCanvas = uscBasicDrawing.Visibility == Visibility.Visible ? uscBasicDrawing.cnvDrawArea : uscViewer.cnvDrawArea;
                switch (type)
                {
                case ComplimentType.COOL:
                    Compliment.CreateNewCompliment(ComplimentType.COOL, activeCanvas);
                    break;

                case ComplimentType.WOW:
                    Compliment.CreateNewCompliment(ComplimentType.WOW, activeCanvas);
                    break;

                case ComplimentType.THANKS:
                    Compliment.CreateNewCompliment(ComplimentType.THANKS, activeCanvas);
                    break;

                case ComplimentType.NICE:
                    Compliment.CreateNewCompliment(ComplimentType.NICE, activeCanvas);
                    break;
                }
            });
        }
示例#3
0
        public async Task <IActionResult> DoCompliment(Compliment compliment)
        {
            string usr = HttpContext.Session.GetString("sEmail");

            if (String.IsNullOrEmpty(usr))
            {
                return(RedirectToAction("Login", "Users"));
            }
            compliment.Reviewer = usr;

            var Complimented = await _context.Compliment.SingleOrDefaultAsync(c => c.Reviewer == usr && c.AdvertiseID == compliment.AdvertiseID);

            if (Complimented == null)
            {
                _context.Add(compliment);
                await _context.SaveChangesAsync();
            }
            else
            {
                Complimented.Cleanness    = compliment.Cleanness;
                Complimented.Comfort      = compliment.Comfort;
                Complimented.PriceQuality = compliment.PriceQuality;
                Complimented.Staff        = compliment.Staff;
                _context.Update(Complimented);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("Details", new { id = compliment.AdvertiseID }));
        }
示例#4
0
 private Compliment GetComplimentByForm(Compliment cp)
 {
     cp.ID_Student = compliment.ID_Student;
     cp.Name       = txtName.Text;
     cp.Note       = txtNote.Text;
     cp.Reason     = txtReason.Text;
     cp.Date       = dateCompliment.Value;
     cp.Degree     = cbbDegree.Text;
     return(cp);
 }
        public async Task <string> Get([FromQuery] string name, [FromQuery] string gender)
        {
            //var list = new Compliment().GetCompliment(gender.ToLower());
            //string json = JsonConvert.SerializeObject(list);
            //return json;
            var complimentObj = new Compliment();
            await complimentObj.GetComplimentFromAPI();

            return(complimentObj.ComplimentProp);
        }
        private void DisplayCompliment(string username, string message, Color backGroundColor)
        {
            Compliment c = new Compliment();
            Border     b = c.CreateTextBlock(username, message, backGroundColor);

            c.MaxHorizontal = (int)cnvViewArea.ActualWidth;
            c.MaxVertical   = (int)cnvViewArea.ActualHeight;

            c.CreateTimer(100, 35, true);

            c.ComplimentDestroyHandler += DestroyCompliment;

            cnvViewArea.Children.Add(b);
        }
示例#7
0
        // Example GET query: http://localhost:xxxx/HelloWorld/Welcome?name=Rick&numtimes=4&gender=female
        public async Task <IActionResult> Index(string name, string gender = "male")
        {
            var complimentObj = new Compliment();

            ViewData["Message"]     = "Hello " + name;
            ViewData["Gender"]      = gender.ToLower();
            ViewData["Compliments"] = complimentObj.GetCompliment(gender.ToLower());
            await complimentObj.GetComplimentFromAPI();

            var compliment = JsonConvert.DeserializeObject <JObject>(complimentObj.ComplimentProp);

            Console.WriteLine($"compliment: {compliment["compliment"]}");
            ViewData["ComplimentFromAPI"] = compliment["compliment"];

            return(View());
        }
示例#8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (ok == true)
     {
         try{
             Compliment tg = new Compliment();
             GetComplimentByForm(tg);
             context.Compliments.Add(tg);
             context.SaveChanges();
             MessageBox.Show("Done");
             LoaddgvCompliment();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         try
         {
             Compliment tg = new Compliment();
             int        id = Convert.ToInt32(txtID.Text);
             tg = context.Compliments.Where(p => p.ID == id).FirstOrDefault();
             GetComplimentByForm(tg);
             context.SaveChanges();
             MessageBox.Show("Done");
             LoaddgvCompliment();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     btnAdd.Enabled    = true;
     btnEdit.Enabled   = true;
     BtnDelete.Enabled = true;
     btnSave.Enabled   = false;
     btnCancel.Enabled = false;
     groupBox1.Enabled = false;
 }
 private void lblThanks_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Compliment.CreateNewCompliment(ComplimentType.THANKS, cnvDrawArea);
     Client.WriteComplimentMessage(ComplimentType.THANKS);
 }
 private void lblNice_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Compliment.CreateNewCompliment(ComplimentType.NICE, cnvDrawArea);
     Client.WriteComplimentMessage(ComplimentType.NICE);
 }