public ActionResult Letters(LetterModel letter) { ClearAlerts("Alert Letters M", 3); // get the list of letters from Session List <LetterModel> letters = getLetters(); // we'll need to validate the data if (letters.Exists(l => l.Name == letter.Name)) { Session.Add("Alert Letters M3", "Letter name is already used. Please change the letter name."); return(View()); } // we need the letter type id to create the letter List <LetterTypeModel> lettertypes = (List <LetterTypeModel>)Session["Letter Types"]; int lettertypeid = lettertypes.Find(lt => lt.Name == letter.LetterType).Id; letter.Id = LetterProcessor.CreateLetter(letter.Name, (int)Session["Language"], lettertypeid, letter.Pronounciation, letter.Description); letters.Add(letter); // lastly, we'll need to clear the values in the field ModelState.SetModelValue("Name", new ValueProviderResult("", "", ModelState["Name"].Value.Culture)); ModelState.SetModelValue("Pronounciation", new ValueProviderResult("", "", ModelState["Pronounciation"].Value.Culture)); ModelState.SetModelValue("Description", new ValueProviderResult("", "", ModelState["Description"].Value.Culture)); return(View()); }
public ActionResult EditGet(long id) { LetterModel model = new LetterModel(); using (ncelsEntities db = new ncelsEntities()) { OBK_LetterPortalEdo dataFromDB = db.OBK_LetterPortalEdo.Where(x => x.ID == id).FirstOrDefault(); if (dataFromDB != null) { model.ID = dataFromDB.ID; model.LetterContent = dataFromDB.LetterContent; model.ContractId = dataFromDB.ContractId; model.RegName = dataFromDB.OBK_LetterRegistration.LetterRegName; model.LetterRegDate = dataFromDB.OBK_LetterRegistration.LetterRegDate; model.AuthorID = dataFromDB.AuthorID; model.LetterStatusId = dataFromDB.LetterStatusId; ViewData["Contract"] = new SelectList(db.OBK_Contract.Where(x => x.EmployeeId == dataFromDB.AuthorID).ToList(), "Id", "Number", dataFromDB.ContractId); var dataDocs = db.OBK_LetterAttachments.Where(x => x.LetterId == model.ID).Select(x => new AttachDoc { AttachmentName = x.AttachmentName, ID = x.ID, isSigned = string.IsNullOrEmpty(x.SignXmlBigData) ? false : true, }).ToList(); model.listDoc = dataDocs; } } return(View(model)); }
public ActionResult Edit(LetterModel model) { using (ncelsEntities db = new ncelsEntities()) { OBK_LetterPortalEdo dataFromDB = db.OBK_LetterPortalEdo.Where(x => x.ID == model.ID).FirstOrDefault(); if (dataFromDB != null) { dataFromDB.LetterContent = model.LetterContent; dataFromDB.ContractId = model.ContractId; dataFromDB.OBK_LetterRegistration.LetterRegName = model.RegName; dataFromDB.OBK_LetterRegistration.LetterRegDate = model.LetterRegDate; db.SaveChanges(); foreach (HttpPostedFileBase file in model.files) { //Checking file is available to save. if (file != null) { string InputFileName = Path.GetFileName(file.FileName); OBK_LetterAttachments attach = new OBK_LetterAttachments(); attach.AttachmentName = InputFileName; attach.ContentFile = StreamToByteArray(file.InputStream); attach.LetterId = dataFromDB.ID; db.OBK_LetterAttachments.Add(attach); db.SaveChanges(); } } } } return(RedirectToAction("Index")); }
public ICollection <LetterModel> GetCategoryByLetter(string id) { List <LetterModel> categoryByLetter = new List <LetterModel>(); var html = new HtmlDocument(); var htmlToLoad = GetHtml("http://misliicitati.blogspot.com/2010/12/blog-post.html"); html.LoadHtml(htmlToLoad); // Select all 'a' nodes that are descendents of // div node with class attributes named 'post-outer', // and having title attribute. var result = html.DocumentNode. SelectNodes("//div[@class='post-outer']//a[@title]"). Where(node => node.InnerText.ToLower(). StartsWith(id.ToLower())); foreach (var item in result) { var categoryContentModel = new LetterModel { Name = item.Attributes[1].Value, Http = item.Attributes[0].Value }; categoryByLetter.Add(categoryContentModel); } return(categoryByLetter); }
private LetterModel DataRowToModel(DataRow row) { LetterModel letter = new LetterModel(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { letter.ID = Convert.ToInt32(row["id"]); } if (row["Title"] != null) { letter.Title = row["Title"].ToString(); } if (row["Content"] != null) { letter.Content = row["Content"].ToString(); } if (row["Receiver"] != null) { letter.Receiver = row["Receiver"].ToString(); } if (row["AddTime"] != null && row["AddTime"].ToString() != null) { letter.AddTime = Convert.ToDateTime(row["AddTime"].ToString()); } } return(letter); }
public ActionResult DeleteOutgoing(long id) { LetterModel model = new LetterModel(); model.ID = id; return(View(model)); }
private void 编辑ToolStripMenuItem1_Click(object sender, EventArgs e) { if (selectId != -1) { LetterModel letter = LetterBll.GetModelById(selectId); FormWriter formWriter = new FormWriter(letter); formWriter.ShowDialog(); } }
// Use this for initialization void Awake() { // Set initial values _neutral = GetComponent<Image>().color; _fingerId = -1; // Get required components _model = GetComponent<LetterModel> (); }
public LetterModel Generate(CustomerModel model, string templateFileName, string outputFolder) { LetterModel result = new LetterModel(); try { result.FileName = string.Concat(outputFolder, model.Id, "_", model.TitleFullName.Replace(' ', '_'), ".txt"); string template = this.fileSystem.ReadTextFile(templateFileName); List <TokenModel> tokenList = new List <TokenModel>(); tokenList.Add(new TokenModel { Token = "{currentDate}", Value = model.CurrentDate }); tokenList.Add(new TokenModel { Token = "{titleFullName}", Value = model.TitleFullName }); tokenList.Add(new TokenModel { Token = "{titleSurname}", Value = model.TitleSurname }); tokenList.Add(new TokenModel { Token = "{productName}", Value = model.ProductName }); tokenList.Add(new TokenModel { Token = "{payoutAmount}", Value = model.PayoutAmount.ToString("F2") }); tokenList.Add(new TokenModel { Token = "{annualPremium}", Value = model.AnnualPremium.ToString("F2") }); tokenList.Add(new TokenModel { Token = "{creditCharge}", Value = model.CreditCharge.ToString("F2") }); tokenList.Add(new TokenModel { Token = "{totalPremium}", Value = model.TotalPremium.ToString("F2") }); tokenList.Add(new TokenModel { Token = "{initialMonthlyPayment}", Value = model.InitialMonthlyPaymentAmount.ToString("F2") }); tokenList.Add(new TokenModel { Token = "{otherMonthlyPayment}", Value = model.OtherMonthlyPaymentAmount.ToString("F2") }); foreach (TokenModel tm in tokenList) { template = template.Replace(tm.Token, tm.Value); } result.Content = template; } catch (Exception e) { this.logger.Log(string.Concat("Generate letter error : ", e.Message)); } return(result); }
public async Task <IActionResult> PutAsync(int id, [FromBody] LetterModel value) { var result = await commoCommandsLetter.UpdateAsync(id, value); if (result <= 0) { return(BadRequest()); } return(Ok(result)); }
public async Task <IActionResult> PostAsync([FromBody] LetterModel value) { var result = await commoCommandsLetter.CreateAsync(value); if (result == 0) { return(BadRequest()); } return(Ok(result)); }
public async Task UpdateLetterTest(int value) { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <LetterDbContext>() .UseSqlite(connection) .Options; using (var context = new LetterDbContext(options)) { context.Database.EnsureCreated(); LetterDbContextInitializer.Initialize(context); } LetterModel letterModel = new LetterModel() { Receivers = new List <ReceiverModel>(), SentStatus = true, SentDate = DateTime.Today, TemplateId = 1 }; using (var context = new LetterDbContext(options)) { LettersCommands lettersCommands = null; Letter letterUpdated = null; try { lettersCommands = this.GetStorageCommand(context); await lettersCommands.UpdateAsync(value, letterModel); letterUpdated = context.Letters.SingleOrDefault(let => let.Id == value); if (letterUpdated == null) { Assert.Null(letterUpdated); return; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } Assert.True(letterUpdated.SentStatus == letterModel.SentStatus); Assert.True(letterUpdated.SentDate == letterModel.SentDate); } }
public ActionResult SignViewStart(LetterModel model) { using (ncelsEntities db = new ncelsEntities()) { var data = db.OBK_LetterAttachments.Where(x => x.LetterId == model.ID).Select(x => new AttachDoc { AttachmentName = x.AttachmentName, ID = x.ID, isSigned = string.IsNullOrEmpty(x.SignXmlBigData) ? false : true, }).ToList(); model.listDoc = data; } return(View(model)); }
public ActionResult DeleteOutgoing(LetterModel model) { using (ncelsEntities db = new ncelsEntities()) { OBK_LetterPortalEdo edo = db.OBK_LetterPortalEdo.Where(x => x.ID == model.ID).FirstOrDefault(); if (edo != null) { db.OBK_LetterPortalEdo.Remove(edo); db.SaveChanges(); db.Database.ExecuteSqlCommand(String.Format("delete from OBK_LetterAttachments where LetterId={0}", model.ID)); // db.OBK_LetterRegistration.Remove(db.OBK_LetterRegistration.Where(x=>x.ID==edo.OBKLetterRegID).FirstOrDefault()); db.SaveChanges(); } } return(RedirectToAction("Index")); }
public ActionResult Letter(int?id) { var letterModel = new LetterModel(); if (id != null) { var acceptMessage = _iMessageServices.GetAcceptMessageById(id.Value); letterModel.Message = _iMessageServices.GetMessageByMessageCode(acceptMessage.MessageCode); acceptMessage.IsRead = true; _iMessageServices.Update(acceptMessage); letterModel.MessageAcceptUserItem = acceptMessage; } letterModel.User = _iUserServices.GetUser().Result; GetMessage(); return(View(letterModel)); }
public async Task <IHttpActionResult> Create([FromBody] LetterModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var letter = new Letter { UserId = Identity.Id, Date = DateTime.Now, Message = model.Message, Title = model.Title }; letter = await LetterCore.CreateAsync(letter); if (letter == null) { return(InternalServerError()); } var user = await UserCore.GetAsync(Identity.Id); if (user.Email == model.Email) { return(Ok(letter)); } user.Email = model.Email; var updatedUser = await UserCore.UpdateAsync(user); if (updatedUser == null) { return(InternalServerError()); } return(Ok(letter)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public ActionResult Index(int currentPage = 1, int type = 2, string title = "", string time = "") { var pageIndex = currentPage - 1; SQL.DataSource.SQLPage <MessageAcceptUser> mesg = null; if (type == 0) { mesg = title.IsNullOrEmpty() ? _iMessageServices.GetAccepMessageByUserId(User.Model.Id, _pageSize, pageIndex) : _iMessageServices.GetAccepMessageByUserId(User.Model.Id, _pageSize, pageIndex, title); } else if (type == 1) { mesg = title.IsNullOrEmpty() ? _iMessageServices.GetAccepMessageByUserIdRead(User.Model.Id, _pageSize, pageIndex) : _iMessageServices.GetAccepMessageByUserIdRead(User.Model.Id, _pageSize, pageIndex, title); } else if (type == 2) { mesg = title.IsNullOrEmpty() ? _iMessageServices.GetAccepMessageByUserIdNoRead(User.Model.Id, _pageSize, pageIndex) : _iMessageServices.GetAccepMessageByUserIdNoRead(User.Model.Id, _pageSize, pageIndex, title); } else if (type == 3) { mesg = title.IsNullOrEmpty() ? _iMessageServices.GetAccepMessageByUserIdImportant(User.Model.Id, _pageSize, pageIndex) : _iMessageServices.GetAccepMessageByUserIdImportant(User.Model.Id, _pageSize, pageIndex, title); } else if (type == 4) { mesg = title.IsNullOrEmpty() ? _iMessageServices.GetAccepMessageByUserIdDelete(User.Model.Id, _pageSize, pageIndex) : _iMessageServices.GetAccepMessageByUserIdDelete(User.Model.Id, _pageSize, pageIndex, title); } ViewBag.page = currentPage; var letterModel = new LetterModel(); letterModel.MessageAcceptUser = GetListMessage(mesg, currentPage); ViewBag.Title = title; ViewBag.Time = time; GetMessage(); return(View(letterModel)); }
public int add(LetterModel letterModel) { string sql = "insert into letter(Title,Content,Receiver,AddTime) values(@Title,@Content,@Receiver,@AddTime);select @@identity"; SqlParameter[] cmdParms = { new SqlParameter("@Title", letterModel.Title), new SqlParameter("@Content", letterModel.Content), new SqlParameter("@Receiver", letterModel.Receiver), new SqlParameter("@AddTime", letterModel.AddTime) }; object obj = SqlHelper.selectSingle(sql, cmdParms); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public ModelConfiguration GetModelConfiguration() { var result = new ModelConfiguration(); result.LetterModels = new List <LetterModel>(); var model1 = new LetterModel() { Color = "Red", OffsetX = -2, OffsetY = 0, OffsetZ = .2 }; var model2 = new LetterModel() { Color = "Blue", OffsetX = -1, OffsetY = .5, OffsetZ = -.2 }; var model3 = new LetterModel() { Color = "Green", OffsetX = 1, OffsetY = .2, OffsetZ = -.1 }; var model4 = new LetterModel() { Color = "Yellow", OffsetX = 2, OffsetY = 0, OffsetZ = .15 }; result.LetterModels.Add(model1); result.LetterModels.Add(model2); result.LetterModels.Add(model3); result.LetterModels.Add(model4); return(result); }
private void buttonSubmit_Click(object sender, EventArgs e) { LetterModel letterModel = new LetterModel(); letterModel.Title = this.textBoxTitle.Text; letterModel.Content = this.textBoxContent.Text; letterModel.Receiver = this.textBoxReceiver.Text; letterModel.AddTime = DateTime.Now; if (LetterBll.DealWriter(letterModel)) { changeListEvent(); MessageBox.Show("发送成功!"); } else { MessageBox.Show("发送失败", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <ActionResult> CreateLetter(LetterModel content) { if (!ModelState.IsValid) { return(View(content)); } ApplicationUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); Debug.WriteLine(user == null); user.Letters.Add(new Letter { Content = content.Letter, DateTimeCreation = DateTime.Now }); await UserManager.UpdateAsync(user); TempData["one-day-warning"] = "You have one day to cancel the letter"; return(RedirectToAction("AllLetters", "Home")); }
public IActionResult Form(LetterModel letter) { Task.Run(() => { MailAddress from = new MailAddress("*****@*****.**", "Mail from gallery"); MailAddress to = new MailAddress("*****@*****.**"); MailMessage m = new MailMessage(from, to); m.Subject = letter.Subject; m.Body = letter.Text + "\n\n\n" + letter.Email + "\t" + letter.Name; SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "test007A"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; smtp.Send(m); }); return(RedirectToAction(nameof(Success))); }
public ActionResult UpdateLetterConfirmed(LetterModel content) { if (!ModelState.IsValid) { return(View(content)); } ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); Letter let = user.Letters.FirstOrDefault(l => l.LetterId == content.LetterId); if (let == null) { return(HttpNotFound()); } let.Content = content.Letter; UserManager.Update(user); return(RedirectToAction("AllLetters", "Home", new { page = content.LetterPage })); }
public void Send(LetterModel letterModel) { var emailMessage = new MimeMessage(); emailMessage.From.Add(new MailboxAddress(letterModel.Login, "*****@*****.**")); emailMessage.To.Add(new MailboxAddress("", _adminEmailAdress)); emailMessage.Subject = _messageSubject; emailMessage.Body = new TextPart(MimeKit.Text.TextFormat.Text) { Text = letterModel.Text }; using (var client = new SmtpClient()) { client.ConnectAsync("smtp.mail.ru", 25, false); client.AuthenticateAsync("*****@*****.**", "alex0000"); client.SendAsync(emailMessage); client.DisconnectAsync(true); } }
public ActionResult AddLetter() { LetterModel model = new LetterModel(); using (ncelsEntities db = new ncelsEntities()) { var employee = db.Employees.FirstOrDefault(x => x.Login == User.Identity.Name); model.AuthorID = employee.Id; var Contracts = db.OBK_Contract.Where(x => x.EmployeeId == employee.Id).ToList(); if (employee != null) { ViewData["Contract"] = new SelectList(Contracts, "Id", "Number"); } if (Contracts.Count != 0) { ViewBag.AtLeastOne = true; } else { ViewBag.AtLeastOne = false; } } return(View(model)); }
public FormWriter(LetterModel letter) { InitializeComponent(); this.letter = letter; }
public LetterPage() { InitializeComponent(); DataContext = new LetterModel(); }
public static bool DealWriter(LetterModel letterModel) { return(false); }
public static bool DealWriter(LetterModel letterModel) { return(new LetterDal().add(letterModel) != 0); }
public ActionResult AddLetter(LetterModel model) { if (model != null) { using (ncelsEntities db = new ncelsEntities()) { OBK_LetterRegistration letterRegistartin = new OBK_LetterRegistration(); letterRegistartin.LetterRegDate = model.LetterRegDate; letterRegistartin.LetterRegName = model.RegName; db.OBK_LetterRegistration.Add(letterRegistartin); db.SaveChanges(); OBK_LetterPortalEdo data = new OBK_LetterPortalEdo(); data.LetterContent = model.LetterContent; data.CreatedDate = DateTime.Now; data.ContractId = model.ContractId; data.AuthorID = model.AuthorID; data.LetterContent = model.LetterContent; data.OBKLetterRegID = letterRegistartin.ID; data.LetterStatusId = model.LetterStatusId;//Pismo prosto sohranen na base db.OBK_LetterPortalEdo.Add(data); db.SaveChanges(); foreach (HttpPostedFileBase file in model.files) { //Checking file is available to save. if (file != null) { string InputFileName = Path.GetFileName(file.FileName); OBK_LetterAttachments attach = new OBK_LetterAttachments(); attach.AttachmentName = InputFileName; attach.ContentFile = StreamToByteArray(file.InputStream); attach.LetterId = data.ID; db.OBK_LetterAttachments.Add(attach); } } model.ID = data.ID; db.SaveChanges(); if (model.LetterStatusId == 2) { var dataDocs = db.OBK_LetterAttachments.Where(x => x.LetterId == model.ID).Select(x => new AttachDoc { AttachmentName = x.AttachmentName, ID = x.ID, isSigned = string.IsNullOrEmpty(x.SignXmlBigData) ? false : true, }).ToList(); model.listDoc = dataDocs; } db.SaveChanges(); } } if (model.LetterStatusId == 2) { if (model.listDoc.Count != 0) { return(View("SignViewStart", model)); } else { //WebSerice return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } }