/// <summary> /// Deprecated Method for adding a new object to the OutgoingMessages EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToOutgoingMessages(OutgoingMessage outgoingMessage) { base.AddObject("OutgoingMessages", outgoingMessage); }
public ActionResult Edit(OutgoingMessage outgoingmessage) { try { if (ModelState.IsValid) { repository.Update<OutgoingMessage>(outgoingmessage); repository.UnitOfWork.SaveChanges(); return RedirectToAction("Index"); } } catch (DataException) { //Log the error (add a variable name after DataException) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return View(outgoingmessage); }
/// <summary> /// Create a new OutgoingMessage object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="recipient">Initial value of the Recipient property.</param> /// <param name="messageType">Initial value of the MessageType property.</param> /// <param name="messageFormat">Initial value of the MessageFormat property.</param> /// <param name="priority">Initial value of the Priority property.</param> /// <param name="message">Initial value of the Message property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="messageClass">Initial value of the MessageClass property.</param> /// <param name="srcPort">Initial value of the SrcPort property.</param> /// <param name="destPort">Initial value of the DestPort property.</param> /// <param name="lastUpdate">Initial value of the LastUpdate property.</param> /// <param name="status">Initial value of the Status property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> public static OutgoingMessage CreateOutgoingMessage(global::System.String id, global::System.String recipient, global::System.String messageType, global::System.String messageFormat, global::System.String priority, global::System.String message, global::System.Int64 quantity, global::System.String messageClass, global::System.Int64 srcPort, global::System.Int64 destPort, global::System.DateTime lastUpdate, global::System.String status, global::System.DateTime createDate) { OutgoingMessage outgoingMessage = new OutgoingMessage(); outgoingMessage.Id = id; outgoingMessage.Recipient = recipient; outgoingMessage.MessageType = messageType; outgoingMessage.MessageFormat = messageFormat; outgoingMessage.Priority = priority; outgoingMessage.Message = message; outgoingMessage.Quantity = quantity; outgoingMessage.MessageClass = messageClass; outgoingMessage.SrcPort = srcPort; outgoingMessage.DestPort = destPort; outgoingMessage.LastUpdate = lastUpdate; outgoingMessage.Status = status; outgoingMessage.CreateDate = createDate; return outgoingMessage; }
public ActionResult SendMessage(OutgoingMessageViewModel msg) { try { if (ModelState.IsValid) { // The To list can be separated by comma or semicolon string[] toList = msg.Recipient.Split(MessageHelper.SupportedSeparators, StringSplitOptions.RemoveEmptyEntries); string groupId = MessageHelper.GenerateUniqueIdentifier(); GatewayConfig gwConfig = repository.First<GatewayConfig>(gc => gc.Id == msg.Channel); repository.UnitOfWork.BeginTransaction(); foreach (string to in toList) { OutgoingMessage message = new OutgoingMessage(); message.Id = MessageHelper.GenerateUniqueIdentifier(); message.GatewayId = msg.Channel; message.Recipient = to.Trim(); if (gwConfig != null) { message.Originator = gwConfig.OwnNumber; } else { message.Originator = string.Empty; } message.MessageType = msg.MessageType; message.MessageFormat = msg.MessageFormat; message.LastUpdate = DateTime.Now; message.CreateDate = message.LastUpdate; message.SrcPort = Convert.ToInt32(msg.SrcPort); message.DestPort = Convert.ToInt32(msg.DestPort); message.Status = "Pending"; message.MessageClass = msg.MessageClass; message.Priority = msg.Priority; message.StatusReport = msg.StatusReport; message.Quantity = 1; message.GroupId = groupId; message.ScheduledDate = msg.ScheduledDate; message.Message = msg.Message; if (msg.MessageType.Equals("WAP Push", StringComparison.OrdinalIgnoreCase)) { message.WapUrl = msg.WapUrl; message.WapSignal = msg.WapSignal; message.WapCreateDate = msg.WapCreateDate; message.WapExpiryDate = msg.WapExpiryDate; } repository.Add<OutgoingMessage>(message); } repository.UnitOfWork.CommitTransaction(); return RedirectToAction("Index"); } } catch (DataException) { if (repository.UnitOfWork.IsInTransaction) { // Rollback the transaction repository.UnitOfWork.RollBackTransaction(); } // Log the error (add a variable name after DataException) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return View(msg); }