public IActionResult AssignMessage(int msgid, string st, AssignActivityMessageDto model) { var actMsg = new ActivityMessage(); actMsg.Activity.Id = model.ActivityId; actMsg.Message.Id = msgid; actMsg.SendingTime.Id = "after"; actMsg.CreatedBy.Id = partnerManager.GetCurrentUserId(this.HttpContext); actMsg.CreatedBy.Account = partnerManager.GetCurrentUserAccount(this.HttpContext); actMsg.MessageOrder = -1; var result = new ActivityMessageRepo(db, partnerManager).Create(actMsg); var activity = new ActivityRepo(db, partnerManager).GetActivity(model.ActivityId); model.Activity = activity; var sendingTime = new CommonCodeRepo(db).GetCodesByType("ActivityMessage.SendingTime"); model.SendingTime = sendingTime; var messages = new MessageTemplateRepo(db, partnerManager).GetAll(activity.Id); var listOfSelectedMessage = new List <SelectedMessages>(); if (messages != null) { foreach (var item in messages) { listOfSelectedMessage.Add(new SelectedMessages { Message = item, SendingTime = sendingTime });; } } model.Messages = listOfSelectedMessage; model.ActivityMessages = new ActivityMessageRepo(db, partnerManager).GetList(activity.Id, -1); return(View(model)); }
public IActionResult AssignMessage(string id) { var activity = new ActivityRepo(db, partnerManager).GetActivity(id); if (activity == null) { toastNotification.AddErrorToastMessage("البيانات غير موجودة ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var model = new AssignActivityMessageDto(); model.ActivityId = activity.Id; model.Activity = activity; var sendingTime = new CommonCodeRepo(db).GetCodesByType("ActivityMessage.SendingTime"); model.SendingTime = sendingTime; var messages = new MessageTemplateRepo(db, partnerManager).GetAll(activity.Id); var listOfSelectedMessage = new List <SelectedMessages>(); if (messages != null) { foreach (var item in messages) { listOfSelectedMessage.Add(new SelectedMessages { Message = item, SendingTime = sendingTime });; } } model.Messages = listOfSelectedMessage; model.ActivityMessages = new ActivityMessageRepo(db, partnerManager).GetList(id, -1); return(View(model)); }