示例#1
0
        public static void SendNotification(EnumNotification notificationType, string url)
        {
            int    projectID   = (int)HttpContext.Current.Session["projectID"];
            int    userID      = (int)HttpContext.Current.Session["userID"];
            string projectName = (string)HttpContext.Current.Session["projectName"];
            string message     = "";

            using (SDTEntities db = new SDTEntities())
            {
                User sender = db.Users.Find(userID);
                List <ProjectUser> receivers = db.ProjectUsers.Where(p => p.ID_Project == projectID && p.ID_User != userID).ToList();
                message = CreateMessage(notificationType, sender, projectName);

                foreach (ProjectUser projectUser in receivers)
                {
                    Notification notification = new Notification();
                    notification.Avatar           = sender.Avatar;
                    notification.ID_User          = projectUser.ID_User;
                    notification.Message          = message;
                    notification.URL              = url;
                    notification.ID_Project       = projectID;
                    notification.DateNotification = DateTime.Now;
                    db.Notifications.Add(notification);
                    db.SaveChanges();
                }
            }
        }
示例#2
0
        private static string CreateMessage(EnumNotification notification, User sender, string projectName)
        {
            string message = "Uživatel " + sender.Name + " " + sender.Surname;

            switch (notification)
            {
            case EnumNotification.CREATE_ACTOR:
                message += CreateActor();
                break;

            case EnumNotification.EDIT_ACTOR:
                message += EditActor();
                break;

            case EnumNotification.DELETE_ACTOR:
                message += DeleteActor();
                break;

            case EnumNotification.CREATE_REQUIREMENT:
                message += CreateRequirement();
                break;

            case EnumNotification.EDIT_REQUIREMENT:
                message += EditRequirement();
                break;

            case EnumNotification.DELETE_REQUIREMENT:
                message += DeleteRequirement();
                break;

            case EnumNotification.CREATE_USECASE:
                message += CreateUseCase();
                break;

            case EnumNotification.EDIT_USECASE:
                message += EditUseCase();
                break;

            case EnumNotification.DELETE_USECASE:
                message += DeleteUseCase();
                break;

            case EnumNotification.CREATE_SCENARIO:
                message += CreateScenario();
                break;

            case EnumNotification.EDIT_SCENARIO:
                message += EditScenario();
                break;

            case EnumNotification.DELETE_SCENARIO:
                message += DeleteScenario();
                break;

            case EnumNotification.CREATE_FILE:
                message += CreateFile();
                break;

            case EnumNotification.DELETE_FILE:
                message += DeleteFile();
                break;

            case EnumNotification.CREATE_TASK:
                message += CreateTask();
                break;

            case EnumNotification.CHANGE_TASK:
                message += ChangeTask();
                break;

            case EnumNotification.DELETE_TASK:
                message += DeleteTask();
                break;
            }
            message += projectName + ".";
            return(message);
        }