public ActionResult SendMessage() { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } User CurrentUser = (User)Session["CurrentUser"]; DateTime dateTime = DateTime.Now; dateTime = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second); Massage msg = new Massage { Read = false, date = dateTime, SenderUserName = CurrentUser.UserName, ReciverUserName = des.Encrypt(Request.Form["DoctorCombo"], "Galit@19"), msg = Request.Form["msg"] }; TryValidateModel(msg); if (ModelState.IsValid) { MassageDal msgDal = new MassageDal(); msgDal.Massages.Add(msg); msgDal.SaveChanges(); } return(View("MassagePage")); }
//按下有違規按鈕後,根據停權或永久停權,更正會員,舉報,留言資料表的資料內容 public ActionResult violate(int?UsId) { Mber mber = context.Mber.Find(UsId); Massage massage = context.Massage.Find(UsId); Report report = context.Report.Find(UsId); mber.UsLkC += 1; mber.UsLkS = true; if (mber.UsLkC == 3) { mber.UsLkT = DateTime.Now; mber.UsULkT = DateTime.Now.AddYears(100); } else { mber.UsLkT = DateTime.Now; mber.UsULkT = DateTime.Now.AddDays(14); } massage.MsRptS = false; massage.MsHdS = true; context.Report.Remove(report); context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(int id, [Bind("MessageId,sender_id,reciever_id,message,created_at")] Massage massage) { if (id != massage.MessageId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(massage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MassageExists(massage.MessageId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["reciever_id"] = new SelectList(_context.Users, "Id", "Id", massage.reciever_id); ViewData["sender_id"] = new SelectList(_context.Users, "Id", "Id", massage.sender_id); return(View(massage)); }
/// <summary> /// Build massagers /// </summary> /// <param name="model"></param> /// <returns></returns> private string BuildMassagers(Model model, Massage massageSequence) { var massagers = from m in model.DataMassages where m.Sequence == massageSequence select m; string code = string.Empty; // No need to proceed further. if (massagers.Count() == 0) { return(string.Empty); } string entityCode = model.Name + " entity = ctx.Item as " + model.Name + ";" + Environment.NewLine; foreach (DataMassageItem item in massagers) { string massagerVarName = item.DataMassager.Name.ToLower(); string massagerName = item.DataMassager.Name; // Instance massager code = "IEntityMassager " + massagerVarName + " = new " + massagerName + "();"; code += massagerVarName + ".Massage(entity." + item.PropertyToMassage + ", entityAction);"; // Static massager ? if (item.IsStatic) { code = massagerName + ".Massage(entity." + item.PropertyToMassage + ", entityAction);"; } } code = entityCode + code + Environment.NewLine; return(code); }
public MsgList() { Massage msg1 = new Massage("系统消息", "快来发送第一条消息吧!"); msg.Add(msg1); // // TODO: 在此处添加构造函数逻辑 // }
//按下有違規按鈕後,舉報資料表刪除此筆舉報,此留言在留在資料表的隱藏狀態欄位變成true public ActionResult unViolate(int?UsId) { Massage massage = context.Massage.Find(UsId); Report report = context.Report.Find(UsId); massage.MsRptS = false; context.Report.Remove(report); context.SaveChanges(); return(RedirectToAction("Index")); }
public void schedule_service_using_interface() { IService facial = new Facial("abc", "A1BeautySalon", "4:30 PM"); IService hairCut = new HairCut("def", "A2HairSalon", "6:30 PM"); IService massage = new Massage("ghi", "A3MassageCenter", "5:40 PM"); facial.ScheduleService().ShouldBe($"scheduled {facial.ServiceType} at {facial.Place} for {facial.Name} at {facial.Time}"); hairCut.ScheduleService().ShouldBe($"scheduled {hairCut.ServiceType} at {hairCut.Place} for {hairCut.Name} at {hairCut.Time}"); massage.ScheduleService().ShouldBe($"scheduled {massage.ServiceType} at {massage.Place} for {massage.Name} at {massage.Time}"); }
public async Task SendMessage(Massage message) { await Clients.All.SendAsync("Recievemessages", new massageContent { MessageId = message.MessageId, sender_id = message.sender_id, reciever_id = message.reciever_id, message = message.message, created_at = message.created_at, Recievername = _usermanager.Users.SingleOrDefault(x => x.Id == message.reciever_id)?.UserName, Sendername = _usermanager.Users.SingleOrDefault(x => x.Id == message.sender_id)?.UserName, }); }
public async Task DeleteMassage(int IdMassage) { var MassageInUser = AnyMassageInUser(Context.User.Identity.Name, IdMassage); if (MassageInUser) { await Clients.All.SendAsync("Delete", IdMassage); Massage mas = await con.Massages.FirstOrDefaultAsync(x => x.Id == IdMassage); con.Massages.Remove(mas); await con.SaveChangesAsync(); } }
public async Task ChangeMassage(int IdMassage, string newContent) { var MassageInUser = AnyMassageInUser(Context.User.Identity.Name, IdMassage); if (MassageInUser) { await Clients.All.SendAsync("Change", IdMassage, newContent); Massage mas = await con.Massages.FirstOrDefaultAsync(x => x.Id == IdMassage); mas.Content = newContent; con.Massages.Update(mas); await con.SaveChangesAsync(); } }
public ActionResult ReadMassage(string sender, DateTime date) { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } User CurrentUser = (User)Session["CurrentUser"]; MassageDal msgDal = new MassageDal(); string encryptedsender = des.Encrypt(sender, "Galit@19"); //Massage m = msgDal.Massages.FirstOrDefault<Massage>(x => x.ReciverUserName == CurrentUser.UserName && x.SenderUserName == encryptedsender); Massage m = msgDal.Massages.FirstOrDefault <Massage>(x => x.ReciverUserName == CurrentUser.UserName && x.SenderUserName == encryptedsender && x.date == date); m.Read = true; msgDal.SaveChanges(); return(RedirectToAction("ReciverMessages")); }
public async Task <JsonResult> sendMessage([Bind("MessageId,reciever_id,message")] Massage massage) { massage.sender_id = _usermanager.GetUserId(User); massage.created_at = DateTime.Now; if (ModelState.IsValid) { _context.Add(massage); await _context.SaveChangesAsync(); var newmessage = _context.Message.SingleOrDefault(x => x.MessageId == massage.MessageId); return(Json(newmessage)); } return(Json("Ok")); }
protected void Button2_Click(object sender, EventArgs e) { Massage msg1 = new Massage(); if (TextBoxName.Text == "" || TextBoxName.Text == "点此改名") { msg1.Username = "******"; } else { msg1.Username = TextBoxName.Text; } if (TextBox2.Text != "") { msg1.Content = TextBox2.Text; MsgList.msg.Add(msg1); MsgList.Test(); Refresh(); } TextBox2.Text = null; }
public async Task Send(string massage) { var Login = Context.User.Identity.Name; User user = await con.Users .Include(x => x.Messages) .FirstOrDefaultAsync(x => x.Login == Login); Massage massageSave = new Massage() { User = user, Content = massage, }; user.Messages.Add(massageSave); con.Users.Update(user); await con.SaveChangesAsync(); MassageMapper MassageMapper = mapper.Map <Massage, MassageMapper>(massageSave); await Clients.All.SendAsync("Send", MassageMapper); }
public async Task <IActionResult> Create([Bind("MessageId,reciever_id,message")] Massage massage, string bidpage, int?jbId, string bidstatus) { massage.sender_id = _usermanager.GetUserId(User); massage.created_at = DateTime.Now; if (ModelState.IsValid) { _context.Add(massage); await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(bidpage)) { RedirectToAction("Bidusers", "TblBids", new { jbId }); } if (jbId != null) { RedirectToAction("Index", "TblBids", new { jbId, bidstatus }); } return(RedirectToAction(nameof(MyMasssages))); } ViewData["reciever_id"] = new SelectList(_context.Users, "Id", "Id", massage.reciever_id); ViewData["sender_id"] = new SelectList(_context.Users, "Id", "Id", massage.sender_id); return(View(massage)); }
public async Task <ActionResult> Car(RCViewVM RatingCarViewVM) { if (RatingCarViewVM != null) { decimal Conveniences = 0, Failure = 0, Maintenance = 0; int number = 0; var comment = new List <Comment>(); var Brand = db.Brand.FirstOrDefault(x => x.Id == RatingCarViewVM.Brand); var Body = db.Body.FirstOrDefault(x => x.Id == RatingCarViewVM.Body); var Generation = db.Generation.FirstOrDefault(x => x.Id == RatingCarViewVM.Generation); var Model = db.Model.FirstOrDefault(x => x.Id == RatingCarViewVM.Model); var Motor = db.Motor.FirstOrDefault(x => x.Id == RatingCarViewVM.Motor); var ratingCarList = db.RatingCar.Where(x => x.Brand.Id == Brand.Id); if (Model != null) { ratingCarList = ratingCarList.Where(x => x.Model.Id == Model.Id); } if (Generation != null) { ratingCarList = ratingCarList.Where(x => x.Generation.Id == Generation.Id); } if (Body != null) { ratingCarList = ratingCarList.Where(x => x.Body.Id == Body.Id); } if (Motor != null) { ratingCarList = ratingCarList.Where(x => x.Motor.Id == Motor.Id); } foreach (var carRating in ratingCarList.ToList()) { if (carRating.Conveniences.Value != 0 && carRating.Failure.Value != 0 && carRating.Maintenance.Value != 0) { number++; Conveniences += carRating.Conveniences.Value; Failure += carRating.Failure.Value; Maintenance += carRating.Maintenance.Value; } var user = await UserManager.FindByIdAsync(carRating.UserId); var Avatar = db.Avatar.FirstOrDefault(x => x.UserId == carRating.UserId); var Massage = new Massage() { Description = carRating.Description, Conveniences = carRating.Conveniences.Description, Failure = carRating.Failure.Description, Maintenance = carRating.Maintenance.Description }; if (Avatar != null) { var Image = Convert.ToBase64String(Avatar.Fream, 0, Avatar.Fream.Length); comment.Add(new Comment { Email = user.Email, Massage = Massage, Image = "data:image/jpeg;base64," + Image }); } else { comment.Add(new Comment { Email = user.Email, Massage = Massage }); } } var model = new RatingCarEntityViewModels() { Brand = Brand, Body = Body, Generation = Generation, Model = Model, Motor = Motor, Conveniences = Conveniences, Failure = Failure, Maintenance = Maintenance, Comment = comment }; return(View(model)); } return(View()); }
private async void Sentbtn_Clicked(object sender, EventArgs e) { Errorlbl.Text = ""; if (Sentbtn.Text == "Verify") { if (VerificationNumber.ToString() == PlaceholderEntry.Text) { rubtn.IsEnabled = true; rpbtn.IsEnabled = true; rpbtn.BackgroundColor = Color.FromHex("#40A4DF"); rubtn.BackgroundColor = Color.FromHex("#BB87FF"); rpbtn.TextColor = Color.White; rubtn.TextColor = Color.White; Errorlbl.Text = null; PlaceholderEntry.IsEnabled = false; PlaceholderEntry.Text = "Code Matched!"; Sentbtn.IsEnabled = false; } else { Errorlbl.Text = "Wrong Verification Number"; } } else { Sentbtn.Text = "Sending Code"; Phonenumber = PlaceholderEntry.Text; string url = "https://api.shikkhanobish.com/api/Master/RecoverInfoStudent"; HttpClient client = new HttpClient(); string jsonData = JsonConvert.SerializeObject(new { phonenumber = Phonenumber }); StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync(url, content).ConfigureAwait(false); string result = await response.Content.ReadAsStringAsync(); student = JsonConvert.DeserializeObject <Student>(result); Username = student.UserName; if (student.UserName != null) { studentorTeacher = 0; VerificationNumber = random.Next(1000, 9999); string text = "Your Username or Password reset verification code is: " + VerificationNumber; Massage ms = new Massage(); await ms.SendMsg(Phonenumber, text).ConfigureAwait(false); if (ms.isSent == true) { MainThread.BeginInvokeOnMainThread(() => { Sentbtn.Text = "Verify"; PlaceholderEntry.Text = null; PlaceholderEntry.Placeholder = "Enter 4 Digit Code"; }); } else { MainThread.BeginInvokeOnMainThread(() => { Sentbtn.Text = "Send"; Errorlbl.Text = "Invalid Number. Maybe number is switched off"; }); } } else { studentorTeacher = 1; Teacher teacher = new Teacher(); string urlt = "https://api.shikkhanobish.com/api/Master/RecoverInfoTeacher"; HttpClient clientt = new HttpClient(); string jsonDatat = JsonConvert.SerializeObject(new { phonenumber = Phonenumber }); StringContent contentt = new StringContent(jsonDatat, Encoding.UTF8, "application/json"); HttpResponseMessage responset = await clientt.PostAsync(urlt, contentt).ConfigureAwait(true); string resultt = await responset.Content.ReadAsStringAsync(); teacher = JsonConvert.DeserializeObject <Teacher> (resultt); if (teacher.UserName != null) { VerificationNumber = random.Next(1000, 9999); string text = "Your Username or Password reset verification code is: " + VerificationNumber; string apiKey = "bdgoQKW5OyLe748FUlrBmgCEXZn3oivhuf"; Massage ms = new Massage(); await ms.SendMsg(Phonenumber, text).ConfigureAwait(false); if (ms.isSent == true) { MainThread.BeginInvokeOnMainThread(() => { Sentbtn.Text = "Verify"; PlaceholderEntry.Text = null; PlaceholderEntry.Placeholder = "Enter 4 Digit Code"; }); } else { MainThread.BeginInvokeOnMainThread(() => { Sentbtn.Text = "Send"; Errorlbl.Text = "Invalid Number. Maybe number is switched off"; }); } } else { MainThread.BeginInvokeOnMainThread(() => { Sentbtn.Text = "Send"; Errorlbl.Text = "There is no account with this phone number"; }); } } } }
/// <summary> /// Initialize /// </summary> public DataMassageItem(string propertyName, Type dataMassagerType, Massage sequence) { PropertyToMassage = propertyName; DataMassager = dataMassagerType; Sequence = sequence; }
private async void wthdrawbtn_Clicked(object sender, EventArgs e) { if (wthdrawbtn.Text == "Send Otp") { if (cpentry.Text == teacher.Password) { string Phonenumber = teacher.PhoneNumber; Random random = new Random(); VerificationNumber = random.Next(1000, 9999); string text = "Shikkhanobish withdrawal request verification code: " + VerificationNumber; Massage ms = new Massage(); await ms.SendMsg(Phonenumber, text).ConfigureAwait(false); if (ms.isSent == true) { MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = "OTP sent to this number: xxxxxxx" + teacher.PhoneNumber[7] + teacher.PhoneNumber[8] + teacher.PhoneNumber[9] + teacher.PhoneNumber[10]; }); MainThread.BeginInvokeOnMainThread(() => { wthdrawbtn.Text = "Confirm"; }); MainThread.BeginInvokeOnMainThread(() => { otpentry.IsVisible = true; }); MainThread.BeginInvokeOnMainThread(() => { cpentry.IsVisible = false; }); MainThread.BeginInvokeOnMainThread(() => { erroelbl.TextColor = Color.Black; }); } else { MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = "Either number is off or out of network."; }); } } else { MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = "Password doesn't match"; }); erroelbl.TextColor = Color.Red; } } else if (wthdrawbtn.Text == "Confirm") { if (VerificationNumber == int.Parse(otpentry.Text)) { pnentry.IsVisible = true; MainThread.BeginInvokeOnMainThread(() => { otpentry.Text = ""; otpentry.Placeholder = "Withdraw amount. Ex: 100"; wthdrawbtn.Text = "Withdraw"; }); wthdrawbtn.BackgroundColor = Color.FromHex("#60ED9D"); MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = ""; }); } else { MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = "Verification code doesn't match"; }); erroelbl.TextColor = Color.Red; } } else if (wthdrawbtn.Text == "Ok") { await Navigation.PopPopupAsync().ConfigureAwait(false); } else { try { int amount = int.Parse(otpentry.Text); if (amount > teacher.RechargedAmount) { erroelbl.Text = "You can't withdraw more than you have"; } else { SetWalletInfo(); MainThread.BeginInvokeOnMainThread(() => { erroelbl.Text = "Withdraw request has sent succefully!"; }); erroelbl.TextColor = Color.Red; wthdrawbtn.Text = "Ok"; erroelbl.TextColor = Color.Black; pnentry.IsVisible = false; cpentry.IsVisible = false; otpentry.IsVisible = false; } } catch (Exception ex) { erroelbl.Text = "Only use variable in withdraw field. Ex: 100"; } erroelbl.TextColor = Color.Red; } }
protected virtual void OnMasssegeChanged(string massage) { Massage?.Invoke(this, massage); }
public async Task SendMassage(Massage massage) => await Clients.All.SendAsync("receiveMassage", massage);