public IActionResult Index(int id)
        {
            if (TempData[notificationMessageKey] != null)
            {
                switch (TempData[notificationTypeKey])
                {
                case notificationSuccess:
                    _toastNotification.AddSuccessToastMessage(TempData[notificationMessageKey].ToString());
                    break;

                case notificationWarning:
                    _toastNotification.AddWarningToastMessage(TempData[notificationMessageKey].ToString());
                    break;

                case notificationError:
                    _toastNotification.AddErrorToastMessage(TempData[notificationMessageKey].ToString());
                    break;
                }
            }

            MinistryTimeLine ministryTimeLine = _ministryTimeLineRepository.Get(id);

            if (ministryTimeLine == null)
            {
                return(View());
            }

            return(View(ministryTimeLine));
        }
Пример #2
0
 public static MinistriesViewModel MapToMinistrViewModel(this MinistryTimeLine model)
 {
     return(new MinistriesViewModel()
     {
         ApprovalDate = model.ApprovalDate,
         ApprovedById = model.ApprovedById,
         ArDescription = model.ArDescription,
         ArName = model.ArName,
         ChangeActionEnum = ChangeActionEnum.Update,
         CreatedById = model.CreatedById,
         CreationDate = model.CreationDate,
         Email = model.Email,
         EnDescription = model.EnDescription,
         EnName = model.EnName,
         Facebook = model.Facebook,
         Id = model.Id,
         IsActive = model.IsActive,
         IsDeleted = model.IsDeleted,
         MinistryTimeLineId = model.Id,
         Order = model.Order ?? 0,
         PeriodAr = model.PeriodAr,
         PeriodEn = model.PeriodEn,
         ImageURL = model.ProfileImageUrl,
         VersionStatusEnum = VersionStatusEnum.Draft,
         Twitter = model.Twitter,
     });
 }
Пример #3
0
        public static MinistryTimeLineViewModel MapToEventdViewModel(this MinistryTimeLine sectionCardVersion)
        {
            MinistryTimeLineViewModel viewModel = new MinistryTimeLineViewModel()
            {
                Id               = sectionCardVersion.Id,
                EnName           = sectionCardVersion.EnName,
                ArName           = sectionCardVersion.ArName,
                EnDescription    = sectionCardVersion.EnDescription,
                ArDescription    = sectionCardVersion.ArDescription,
                Order            = sectionCardVersion.Order,
                IsActive         = sectionCardVersion.IsActive,
                ProfileImageUrl  = sectionCardVersion.ProfileImageUrl,
                StartDate        = sectionCardVersion.StartDate,
                EndDate          = sectionCardVersion.EndDate,
                EventSocialLinks = sectionCardVersion.EventSocialLinks,


                SeoTitleEN       = sectionCardVersion.SeoTitleEN,
                SeoTitleAR       = sectionCardVersion.SeoTitleAR,
                SeoDescriptionEN = sectionCardVersion.SeoDescriptionEN,
                SeoDescriptionAR = sectionCardVersion.SeoDescriptionAR,
                SeoOgTitleEN     = sectionCardVersion.SeoOgTitleEN,
                SeoOgTitleAR     = sectionCardVersion.SeoOgTitleAR,
                SeoTwitterCardEN = sectionCardVersion.SeoTwitterCardEN,
                SeoTwitterCardAR = sectionCardVersion.SeoTwitterCardAR,

                IsDeleted    = sectionCardVersion.IsDeleted,
                CreationDate = sectionCardVersion.CreationDate,
                CreatedById  = sectionCardVersion.CreatedById
            };

            return(viewModel);
        }
Пример #4
0
        public static MinistryTimeLine MapToMinistryTimeLine(this MinistryTimeLineViewModel sectionCardCreateViewModel)
        {
            MinistryTimeLine pageSectionVersion = new MinistryTimeLine();

            pageSectionVersion.EnName           = sectionCardCreateViewModel.EnName;
            pageSectionVersion.ArName           = sectionCardCreateViewModel.ArName;
            pageSectionVersion.EnDescription    = sectionCardCreateViewModel.EnDescription;
            pageSectionVersion.ArDescription    = sectionCardCreateViewModel.ArDescription;
            pageSectionVersion.ProfileImageUrl  = sectionCardCreateViewModel.ProfileImageUrl;
            pageSectionVersion.Order            = sectionCardCreateViewModel.Order;
            pageSectionVersion.IsActive         = sectionCardCreateViewModel.IsActive;
            pageSectionVersion.StartDate        = sectionCardCreateViewModel.StartDate;
            pageSectionVersion.EndDate          = sectionCardCreateViewModel.EndDate;
            pageSectionVersion.EventSocialLinks = sectionCardCreateViewModel.EventSocialLinks;
            pageSectionVersion.SeoTitleEN       = sectionCardCreateViewModel.SeoTitleEN;
            pageSectionVersion.SeoTitleAR       = sectionCardCreateViewModel.SeoTitleAR;
            pageSectionVersion.SeoDescriptionEN = sectionCardCreateViewModel.SeoDescriptionEN;
            pageSectionVersion.SeoDescriptionAR = sectionCardCreateViewModel.SeoDescriptionAR;
            pageSectionVersion.SeoOgTitleEN     = sectionCardCreateViewModel.SeoOgTitleEN;
            pageSectionVersion.SeoOgTitleAR     = sectionCardCreateViewModel.SeoOgTitleAR;
            pageSectionVersion.SeoTwitterCardEN = sectionCardCreateViewModel.SeoTwitterCardEN;
            pageSectionVersion.SeoTwitterCardAR = sectionCardCreateViewModel.SeoTwitterCardAR;
            if (sectionCardCreateViewModel.Id > 0)
            {
                pageSectionVersion.Id = sectionCardCreateViewModel.Id;
            }
            //else
            //    pageSectionVersion.Id = 5;
            return(pageSectionVersion);
        }
        public IActionResult Edit(int id)
        {
            MinistryTimeLine pageSectionCardVersion = _ministryTimeLineRepository.GetDetail(id);


            MinistryTimeLineViewModel viewModel = pageSectionCardVersion.MapToEventdViewModel();

            return(View(viewModel));
        }
        public MinistryTimeLine Update(MinistryTimeLine pageMinistry)
        {
            try
            {
                _db.MinistryTimeLine.Attach(pageMinistry);
                _db.Entry(pageMinistry).State = EntityState.Modified;
                _db.SaveChanges();

                return(_db.MinistryTimeLine.FirstOrDefault(c => c.Id == pageMinistry.Id));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public MinistryTimeLine Add(MinistryTimeLine pageMinistry)
        {
            try
            {
                pageMinistry.StatusId = (int)RequestStatus.Approved;
                _db.MinistryTimeLine.Add(pageMinistry);
                _db.SaveChanges();

                return(_db.MinistryTimeLine.FirstOrDefault(c => c.Id == pageMinistry.Id));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public IActionResult Delete(int id)
        {
            MinistryTimeLine pageSectionCardVersion = _ministryTimeLineRepository.Delete(id);

            if (pageSectionCardVersion != null)
            {
                TempData[notificationMessageKey] = ToasrMessages.DeleteSuccess;
                TempData[notificationTypeKey]    = notificationSuccess;

                _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Delete, "Static Page > Ministry Time Line > Delete", " Id :" + id);

                return(Json(new { }));
            }

            TempData[notificationMessageKey] = "Error has been occurred.";
            TempData[notificationTypeKey]    = notificationError;
            return(Json(new { }));
        }
        public async Task <IActionResult> EditAsync(MinistryTimeLineViewModel sectionCardViewModel)
        {
            if (ModelState.IsValid)
            {
                MinistryTimeLine sectionCardVersion = sectionCardViewModel.MapToMinistryTimeLine();

                var user = await _userManager.GetUserAsync(HttpContext.User);

                sectionCardVersion.ApprovedBy   = user;// user.Id.ToString();
                sectionCardVersion.ApprovedById = user.Id.ToString();
                sectionCardVersion.ApprovalDate = DateTime.Now;
                sectionCardVersion.CreationDate = DateTime.Now;
                sectionCardVersion.StatusId     = (int)RequestStatus.Approved;
                if (sectionCardViewModel.Photo != null)
                {
                    sectionCardVersion.ProfileImageUrl = _fileService.UploadImageUrl(sectionCardViewModel.Photo);
                }


                MinistryTimeLine newSectionCardVersion = _ministryTimeLineRepository.Update(sectionCardVersion);
                if (newSectionCardVersion != null)
                {
                    _toastNotification.AddSuccessToastMessage(ToasrMessages.EditSuccess);

                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Update, "Static Page > Ministry Time Line > Edit", sectionCardViewModel.EnName);

                    return(RedirectToAction("Index", new { id = newSectionCardVersion.Id }));
                }
                else
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Static Page > Ministry Time Line > Edit", sectionCardViewModel.EnName);
                    _toastNotification.AddErrorToastMessage(ToasrMessages.warning);
                }
            }

            return(View(sectionCardViewModel));
        }
        public async Task <IActionResult> CreateAsync(MinistryTimeLineViewModel pageMinistryViewModel)
        {
            pageMinistryViewModel.StartDate = Convert.ToDateTime(pageMinistryViewModel.EventDateRange.Split('-')[0]);
            pageMinistryViewModel.EndDate   = Convert.ToDateTime(pageMinistryViewModel.EventDateRange.Split('-')[1]);

            if (ModelState.IsValid)
            {
                MinistryTimeLine sectionCardVersion = pageMinistryViewModel.MapToMinistryTimeLine();// .MapToPageMinistry();

                var user = await _userManager.GetUserAsync(HttpContext.User);

                sectionCardVersion.StatusId     = (int)RequestStatus.Approved;
                sectionCardVersion.CreatedById  = user.Id;
                sectionCardVersion.CreationDate = DateTime.Now;
                sectionCardVersion.ApprovedById = user.Id;
                sectionCardVersion.ApprovedBy   = user;
                sectionCardVersion.ApprovalDate = DateTime.Now;

                if (pageMinistryViewModel.Photo != null)
                {
                    sectionCardVersion.ProfileImageUrl = _fileService.UploadImageUrl(pageMinistryViewModel.Photo);
                }
                MinistryTimeLine newPageSectionCardVersion = _ministryTimeLineRepository.Add(sectionCardVersion);
                if (newPageSectionCardVersion != null)
                {
                    _toastNotification.AddSuccessToastMessage(ToasrMessages.AddSuccess);
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Static Page > Ministry Time Line > Edit", pageMinistryViewModel.EnName);
                    return(RedirectToAction("Index", new { id = newPageSectionCardVersion.Id }));
                }
                else
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Static Page > Ministry Time Line > Edit", pageMinistryViewModel.EnName);
                    _toastNotification.AddErrorToastMessage(ToasrMessages.warning);
                }
            }
            return(View(pageMinistryViewModel));
        }
        public IActionResult Details(int id)
        {
            MinistryTimeLine pageSectionCardVersion = _ministryTimeLineRepository.GetDetail(id);

            return(View(pageSectionCardVersion));
        }