示例#1
0
        public string Create(Event objEvent, string token)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    objEvent.InsertedBy = _userStatistics.UserId;
                    objEvent.InsertedOn = DateTime.Now;
                    if (this.repository.CreateEvent(objEvent))
                    {
                        List<ELetter> objEletterList = this.repository.GetUsersForEvent(objEvent.EventId);
                        ELetter objEletter = null;
                        foreach (var eLetter in objEletterList)
                        {
                            objEletter = new ELetter();
                            objEletter.UserId = eLetter.UserId;
                            objEletter.EventId = eLetter.EventId;
                            objEletter.TemplateId = eLetter.TemplateId;
                            objEletter.OrganizationId = eLetter.OrganizationId;
                            objEletter.InsertedBy = _userStatistics.UserId;
                            this.repository.CreateEletter(objEletter);
                        }
                        SaveFiles(token, this.GetType().Name, objEvent.EventId);
                        return Convert.ToString(true);
                    }
                    return Convert.ToString(false);
                }

                return Convert.ToString(false);
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }
示例#2
0
        public ActionResult Create()
        {
            Event objEvent = new Event();

            SelectList courseList = null;
            SelectList classList = null;
            SelectList organizationList = null;
            SelectList sectionList = null;
            SelectList eventTypeList = null;
            SelectList notificationTypeList = null;

            LoadSelectLists(out classList, out courseList, out organizationList, out sectionList, out eventTypeList, out notificationTypeList, false);

            objEvent.OrganizationList = organizationList;
            objEvent.CourseList = courseList;
            objEvent.ClassList = classList;
            objEvent.SectionList = sectionList;
            objEvent.EventTypeList = eventTypeList;
            objEvent.NotificationTypeList = notificationTypeList;

            objEvent.OrganizationId = ViewBag.OrganizationId == null ? 0 : Convert.ToInt32(ViewBag.OrganizationId);

            return PartialView(objEvent);
        }
示例#3
0
        public bool CreateEvent(Event objEvent)
        {
            var parameters = new
            {
                EventTypeId = objEvent.EventTypeId,
                EventName = objEvent.EventName,
                Description = objEvent.Description,
                StartDate = objEvent.StartDate,
                EndDate = objEvent.EndDate,
                StartTime = objEvent.StartTime,
                EndTime = objEvent.EndTime,
                IsActive = objEvent.IsActive,
                NotificationTypeId = objEvent.NotificationTypeId,
                OrganizationId = objEvent.OrganizationId,
                CourseId = objEvent.CourseId,
                ClassId = objEvent.ClassId,
                SectionId = objEvent.SectionId,
                InsertedOn = objEvent.InsertedOn,
                InsertedBy = objEvent.InsertedBy
            };

            using (IDbConnection connection = OpenConnection())
            {
                const string storedProcedure = "usp_AddEvent";
                int rowsAffected = connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
                SetIdentity<int>(connection, id => objEvent.EventId = id);
                if (rowsAffected > 0)
                {
                    return true;
                }
                return false;
            }
        }