示例#1
0
        public ViewResult EditColumnRequest(long id)
        {
            var columnRequest
                = columnRequestsRepository.ColumnRequests
                  .FirstOrDefault(r => r.Id == id && r.Author.Name == User.Identity.Name)
                  ?? GetPlaceholderColumnRequest();

            if (columnRequest.Status == ColumnRequestStatus.Revised)
            {
                Alert.Add(this,
                          AlertType.Warning,
                          "Revizija",
                          "Administrator je pregledao vašu kolumnu i predložio izmjene.",
                          columnRequest.AdminRemarks);
            }

            if (columnRequest.Status == ColumnRequestStatus.Rejected)
            {
                Alert.Add(this,
                          AlertType.Error,
                          "Odbijeno",
                          "Administrator je odbio vašu kolumnu.",
                          columnRequest.AdminRemarks);
            }

            if (columnRequest.Status == ColumnRequestStatus.Approved)
            {
                Alert.Add(this,
                          AlertType.Success,
                          "Odobreno",
                          "Administrator je odobrio i objavio vašu kolumnu!");
            }

            return(View(nameof(EditColumnRequest), columnRequest));
        }
示例#2
0
        private ViewResult ReviseColumnRequest(ColumnRequest columnRequest)
        {
            columnRequest.Status = ColumnRequestStatus.Revised;
            columnRequestsRepo.EditColumnRequest(columnRequest);

            Alert.Add(this, AlertType.Warning, "Kolumna spremljena kao revizija.");
            return(Column());
        }
示例#3
0
        private ViewResult RejectColumnRequest(ColumnRequest columnRequest)
        {
            columnRequest.Status = ColumnRequestStatus.Rejected;
            columnRequestsRepo.EditColumnRequest(columnRequest);

            Alert.Add(this, AlertType.Error, "Kolumna odbijena.");
            return(Column());
        }
        /// <summary>
        /// Called when we have determined that we have 1 or more alert notification files which need
        /// to be uploaded.
        /// </summary>
        /// <param name="notifications"></param>
        protected void UploadNotifications(AlertNotificationFileList notificationFiles)
        {
            LogFile ourLog = LogFile.Instance;

            try
            {
                // Load the list of Alert Definitions as we will need to match these against the notifications
                AlertMonitorSettings alertMonitorSettings = AlertMonitorSettings.Load();
                //
                foreach (AlertNotificationFile notificationFile in notificationFiles.AlertNotificationFiles)
                {
                    ourLog.Write("Uploading Alert Notifications for " + notificationFile.AssetName, true);

                    // locate the asset for which these notifications have been created
                    //int assetID = lwDataAccess.AssetFind(notificationFile.AssetName, String.Empty);

                    // Skip any notifications for assets which we do not know about
                    //if (assetID == 0)
                    //    continue;

                    // The file may contain 1 or more individual alert triggers so iterate through them now
                    foreach (AlertNotification notification in notificationFile.AlertNotifications)
                    {
                        // We need to find the Alert Definition for which this alert has been generated
                        //AlertDefinition alertDefinition = alertMonitorSettings.FindAlert(notification.AlertName);
                        //if (alertDefinition == null)
                        //    continue;

                        // Create an alert in the database
                        Alert newAlert = new Alert();
                        newAlert.Type      = Alert.AlertType.alertmonitor;
                        newAlert.Category  = Alert.AlertCategory.changed;
                        newAlert.AssetName = notificationFile.AssetName;
                        newAlert.AlertName = notification.AlertName;
                        //
                        if (notification.Category != "")
                        {
                            newAlert.Message = notification.Category + @"\" + notification.Key;
                        }
                        else
                        {
                            newAlert.Message = notification.Key;
                        }
                        newAlert.Field1 = notification.OldValue;
                        newAlert.Field2 = notification.NewValue;

                        // Add the alert to the database
                        newAlert.Add();
                        ourLog.Write("....ADDING AN ALERT TO THE DATABASE, ID was " + newAlert.AlertID.ToString(), true);
                    }
                }
            }

            catch (Exception ex)
            {
                ourLog.Write("Exception occurred in [UploadNotifications], Exception Text is is " + ex.Message, true);
            }
        }
示例#5
0
 public IActionResult EditProfile(Author author)
 {
     if (ModelState.IsValid)
     {
         columnRepository.SaveAuthor(author);
         Alert.Add(this, AlertType.Success, "Profil uspješno izmijenjen!");
         return(RedirectToAction("Index", "AuthorInterface"));
     }
     else
     {
         Alert.Add(this, AlertType.Error,
                   "Greška",
                   "Došlo je do pogreške. Molimo provjerite upisane podatke");
         return(Index());
     }
 }
示例#6
0
        public APNsNotification(string deviceToken, string bundleId, string body, string title = "")
        {
            if (string.IsNullOrWhiteSpace(body))
            {
                throw new ArgumentException("Body must be set!");
            }

            Alert.Add("body", body);

            if (!string.IsNullOrWhiteSpace(title))
            {
                Alert.Add("title", title);
            }

            DeviceToken = deviceToken;
            BundleId    = bundleId;
        }
示例#7
0
        public RedirectToActionResult RemoveColumnRequest(long id)
        {
            var columnRequestExists = columnRequestsRepository.ColumnRequests
                                      .Any(r => r.Id == id && r.Author.Name == User.Identity.Name);

            if (columnRequestExists)
            {
                columnRequestsRepository.RemoveColumnRequest(id);

                Alert.Add(this, AlertType.Success, "Skica uspješno izbrisana.");
            }
            else
            {
                Alert.Add(this, AlertType.Error, "Greška: Skica ne postoji!");
            }

            return(RedirectToAction("Index", "AuthorInterface"));
        }
示例#8
0
        private ViewResult PublishColumnRequest(ColumnRequest columnRequest)
        {
            columnRequest.Status       = ColumnRequestStatus.Approved;
            columnRequest.DateApproved = DateTime.Now;
            columnRequestsRepo.EditColumnRequest(columnRequest);

            var columnPost = new ColumnPost
            {
                DatePosted = columnRequest.DateApproved,
                Author     = columnRequest.Author,
                Title      = columnRequest.ColumnTitle,
                Image      = columnRequest.ColumnImage,
                Text       = columnRequest.ColumnText
            };

            columnRepo.AddColumn(columnPost);

            Alert.Add(this, AlertType.Success, "Kolumna objavljena!");
            return(Column());
        }
示例#9
0
        private void EditExistingColumnRequest(ColumnRequest columnRequest, string command)
        {
            if (columnRequest.Status != ColumnRequestStatus.Rejected &&
                columnRequest.Status != ColumnRequestStatus.Approved)
            {
                if (command == "saveAndSend")
                {
                    Alert.Add(this, AlertType.Success, "Kolumna uspješno spremljena i poslana na pregled.");
                    columnRequest.Status        = ColumnRequestStatus.Pending;
                    columnRequest.DateRequested = DateTime.Now;
                }

                columnRequestsRepository.EditColumnRequest(columnRequest);
            }
            else
            {
                Alert.Add(this, AlertType.Error,
                          "Greška",
                          "Mogu se uređivati samo skice ");
            }
        }
示例#10
0
        private void AddNewColumnRequest(ColumnRequest columnRequest, string command)
        {
            if (columnRequest.Status == ColumnRequestStatus.Draft)
            {
                if (command == "saveAndSend")
                {
                    Alert.Add(this, AlertType.Success, "Kolumna uspješno spremljena i poslana na pregled.");
                    columnRequest.Status        = ColumnRequestStatus.Pending;
                    columnRequest.DateRequested = DateTime.Now;
                }
                else
                {
                    Alert.Add(this, AlertType.Success, "Kolumna uspješno spremljena kao skica.");
                }

                columnRequest.Id = 0;
                columnRequestsRepository.AddColumnRequest(columnRequest);
            }
            else
            {
                throw new InvalidOperationException("Tried to Add a new ColumnRequest with a non-default (Draft) Status");
            }
        }
示例#11
0
        public async Task <IActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                Alert.Add(this, AlertType.Error, "Došlo je do pogreške. Molimo, provjerite upisane podatke.");
                return(Index());
            }

            var user = await userManager.FindByNameAsync(User.Identity.Name);

            var result = await userManager.ChangePasswordAsync(user, model.CurrentPassword, model.NewPassword);

            if (result.Succeeded)
            {
                Alert.Add(this, AlertType.Success, "Lozinka uspješno promijenjena!");
            }
            else
            {
                Alert.Add(this, AlertType.Error, "Došlo je do pogreške. Molimo, provjerite upisane podatke.");
            }

            return(RedirectToAction("Index", "AuthorInterface"));
        }