示例#1
0
        public async Task <ActionResult> CreateOrEdit(int?id)
        {
            if (!id.HasValue)
            {
                return(View(new ScholarshipDto()));
            }
            var elm = await _scholarshipAppService.Get(id.Value);

            return(View(elm));
        }
        public async Task <ActionResult> Schedule(int?id, int?entityId, string entitype, bool showAlert = false)
        {
            ViewBag.EntityType = entitype;
            if (id.HasValue)
            {
                var notification = await _notificationAppService.Get(id.Value);

                return(View(notification));
            }
            if (!entityId.HasValue)
            {
                return(View(new NotificationDto()
                {
                    AssignedTo = entitype
                }));
            }
            NotificationDto model;

            switch (entitype)
            {
            case "feeds":
                var feed = await _feedAppService.Get(entityId.Value);

                model = new NotificationDto()
                {
                    AssignedTo   = "feeds",
                    DataObj      = new DataMessageRequest("feeds", entityId.Value, showAlert),
                    Message      = feed.Description,
                    Title        = feed.Title,
                    AssignedToId = entityId.Value
                };
                model.TurnToData();
                return(View(model));

            case "courses":
                var course = await _courseAppService.Get(entityId.Value);

                model = new NotificationDto()
                {
                    AssignedTo   = "courses",
                    DataObj      = new DataMessageRequest("courses", entityId.Value, showAlert),
                    Message      = course.Description,
                    Title        = course.Title,
                    AssignedToId = entityId.Value
                };
                model.TurnToData();
                return(View(model));

            case "scholarships":
                var scholarship = await _scoralshipAppService.Get(entityId.Value);

                model = new NotificationDto()
                {
                    AssignedTo   = "scholarships",
                    DataObj      = new DataMessageRequest("scholarships", entityId.Value, showAlert),
                    Message      = scholarship.Description,
                    Title        = scholarship.Title,
                    AssignedToId = entityId.Value
                };
                model.TurnToData();
                return(View(model));

            case "messages":
                var message = await _dialyMessageAppService.Get(entityId.Value);

                model = new NotificationDto()
                {
                    AssignedTo   = "messages",
                    DataObj      = new DataMessageRequest("messages", entityId.Value, showAlert),
                    Message      = message.Description,
                    Title        = message.Title,
                    AssignedToId = entityId.Value
                };
                model.TurnToData();
                return(View(model));
            }
            return(View(new NotificationDto()));
        }