public ActionResult ViewInboxMessage(long MessageId) { StoPMessageHeaderModel M = new StoPMessageHeaderModel(); try { var H = Connection.SMGT_getStoPMessageView(MessageId).SingleOrDefault(); M.MessageId = H.MessageId; M.Message = H.Message.Replace("<br />", "\r\n"); M.MessageType = Convert.ToInt64(H.MessageType); M.MessageTypeDes = H.MessageTypeDescription; M.SchoolId = H.SchoolId; M.SeqNo = H.SeqNo; M.Subject = H.Subject; M.Sender = H.Sender; List <tblSchoolToParentMessageAttachment> AList = Connection.tblSchoolToParentMessageAttachments.Where( x => x.MessageId == MessageId).ToList(); M.AttachmentList = AList; } catch (Exception Ex) { Errorlog.ErrorManager.LogError("ActionResult ViewInboxMessage(long MessageId) @ PSMessageController", Ex); } return(PartialView("InboxMsgView", M)); }
public ActionResult NewMessage(StoPMessageHeaderModel Model) { string result = "Success"; using (SchoolMGTEntitiesConnectionString Connection = new SchoolMGTEntitiesConnectionString()) { using (var scope = new TransactionScope()) { try { tblSchoolToParentMessageHeader MsgHead = new tblSchoolToParentMessageHeader(); MsgHead.SchoolId = _session.School_Id; MsgHead.MessageId = Model.MessageId; MsgHead.Message = Model.Message.Replace("\r\n", "<br />"); MsgHead.CreatedBy = _session.User_Id; MsgHead.CreatedDate = DateTime.Now; MsgHead.MessageType = Model.MessageType; MsgHead.IsActive = "Y"; MsgHead.Sender = Model.Sender; MsgHead.Subject = Model.Subject; Connection.SaveChanges(); //MsgHead.Attachments = 0; Connection.tblSchoolToParentMessageHeaders.Add(MsgHead); if (Model.ParentId != -1) { for (int i = 0; i < Model.ParentIdArray.Length; i++) { tblSchoolToParentMessageDetail MsgDetail = new tblSchoolToParentMessageDetail(); MsgDetail.SchoolId = _session.School_Id; MsgDetail.MessageId = Convert.ToInt64(Model.MessageId);; MsgDetail.ParentId = Model.ParentIdArray[i]; MsgDetail.IsActive = "Y"; MsgDetail.Status = "N"; MsgDetail.CreatedBy = _session.User_Id; MsgDetail.CreatedDate = DateTime.Now; Connection.tblSchoolToParentMessageDetails.Add(MsgDetail); Connection.SaveChanges(); } } else { tblSchoolToParentMessageDetail MsgDetail = new tblSchoolToParentMessageDetail(); MsgDetail.SchoolId = _session.School_Id; MsgDetail.MessageId = Convert.ToInt64(Model.MessageId);; MsgDetail.ParentId = -1; MsgDetail.IsActive = "Y"; MsgDetail.Status = "N"; MsgDetail.CreatedBy = _session.User_Id; MsgDetail.CreatedDate = DateTime.Now; Connection.tblSchoolToParentMessageDetails.Add(MsgDetail); Connection.SaveChanges(); } result = "Success"; scope.Complete(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Errorlog.ErrorManager.LogError("SendParenttoSchoolMsg(PtoSMessageHeaderModel Model) @PSMessageController", dbEx); result = "Validation"; } catch (Exception Ex) { Errorlog.ErrorManager.LogError("SendParenttoSchoolMsg(PtoSMessageHeaderModel Model) @PSMessageController", Ex); result = "Exception"; } } } return(Json(result, JsonRequestBehavior.AllowGet)); }