コード例 #1
0
        public async Task EditOfficerNotes([FromBody] EditNotes editDetails)
        {
            var user = await this.userManager.GetUserAsync(HttpContext.User);

            if (!(await this.UserCanEditNotes(editDetails.ProfileId, user)))
            {
                throw new UserReportableError($"This user does not have permission to edit officer notes for profile '{editDetails.ProfileId}'.",
                                              (int)HttpStatusCode.Unauthorized);
            }

            await this.dataRepo.EditOfficerNotes(editDetails.ProfileId, editDetails.PlayerMainId, editDetails.NewNotes);
        }
コード例 #2
0
        /// <summary>
        /// Allows the user to input notes that should be linked to the selected object.
        /// TODO: Should be linked back to CharacterShared in some way or moved into a more generic helper class.
        /// </summary>
        /// <param name="objNotes"></param>
        /// <param name="treNode"></param>
        private async ValueTask WriteNotes(IHasNotes objNotes, TreeNode treNode)
        {
            using (EditNotes frmItemNotes = new EditNotes(objNotes.Notes, objNotes.NotesColor))
            {
                await frmItemNotes.ShowDialogSafeAsync(this);

                if (frmItemNotes.DialogResult != DialogResult.OK)
                {
                    return;
                }

                objNotes.Notes      = frmItemNotes.Notes;
                objNotes.NotesColor = frmItemNotes.NotesColor;
            }
            treNode.ForeColor   = objNotes.PreferredColor;
            treNode.ToolTipText = objNotes.Notes.WordWrap();
            MakeDirty?.Invoke(this, EventArgs.Empty);
        }
コード例 #3
0
        public ActionResult EditNotes(int id)
        {
            Context.Users    user        = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();
            NoteDetail       note        = dobj.NoteDetail.Where(x => x.ID == id && x.IsActive == true && x.SellerID == user.ID).FirstOrDefault();
            NotesAttachments attachement = dobj.NotesAttachments.Where(x => x.NoteID == id).FirstOrDefault();

            if (note != null)
            {
                EditNotes viewModel = new EditNotes
                {
                    ID             = note.ID,
                    NoteID         = note.ID,
                    Title          = note.Title,
                    Category       = note.Category,
                    Picture        = note.DisplayPicture,
                    Note           = attachement.FileName,
                    NumberofPages  = note.NumberofPages,
                    Description    = note.Description,
                    NoteType       = note.NoteType,
                    UniversityName = note.UniversityName,
                    Course         = note.Course,
                    CourseCode     = note.CourseCode,
                    Country        = note.Country,
                    Professor      = note.Professor,
                    IsPaid         = note.IsPaid,
                    SellingPrice   = note.SellingPrice,
                    Preview        = note.NotesPreview,

                    NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList(),
                    NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList(),
                    CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList(),
                };

                return(View(viewModel));
            }
            else
            {
                return(HttpNotFound());
            }
        }
コード例 #4
0
        private async void tssLimitModifierNotes_Click(object sender, EventArgs e)
        {
            if (treLimit.SelectedNode == null)
            {
                return;
            }
            if (treLimit.SelectedNode?.Tag is IHasNotes objNotes)
            {
                await WriteNotes(objNotes, treLimit.SelectedNode);
            }
            else
            {
                // the limit modifier has a source
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType != Improvement.ImprovementType.LimitModifier ||
                        objImprovement.SourceName != treLimit.SelectedNode?.Tag.ToString())
                    {
                        continue;
                    }
                    using (EditNotes frmItemNotes = new EditNotes(objImprovement.Notes, objImprovement.NotesColor))
                    {
                        await frmItemNotes.ShowDialogSafeAsync(this);

                        if (frmItemNotes.DialogResult != DialogResult.OK)
                        {
                            continue;
                        }

                        objImprovement.Notes = frmItemNotes.Notes;
                    }
                    treLimit.SelectedNode.ForeColor   = objImprovement.PreferredColor;
                    treLimit.SelectedNode.ToolTipText = objImprovement.Notes.WordWrap();
                    MakeDirty?.Invoke(this, EventArgs.Empty);
                }
            }
        }
コード例 #5
0
        private void InitializeTable()
        {
            _table = new TableView <Power>
            {
                Dock    = DockStyle.Top,
                ToolTip = _tipTooltip
            };
            // create columns
            TableColumn <Power> nameColumn = new TableColumn <Power>(() => new TextTableCell())
            {
                Text      = "Power",
                Extractor = (power => power.CurrentDisplayName),
                Tag       = "String_Power",
                Sorter    = (name1, name2) => string.Compare((string)name1, (string)name2, GlobalSettings.CultureInfo, CompareOptions.Ordinal)
            };

            nameColumn.AddDependency(nameof(Power.CurrentDisplayName));

            TableColumn <Power> actionColumn = new TableColumn <Power>(() => new TextTableCell())
            {
                Text      = "Action",
                Extractor = (power => power.DisplayAction),
                Tag       = "ColumnHeader_Action",
                Sorter    = (action1, action2) => string.Compare((string)action1, (string)action2, GlobalSettings.CultureInfo, CompareOptions.Ordinal)
            };

            actionColumn.AddDependency(nameof(Power.DisplayAction));

            TableColumn <Power> ratingColumn = new TableColumn <Power>(() => new SpinnerTableCell <Power>(_table)
            {
                EnabledExtractor = (p => p.LevelsEnabled),
                MaxExtractor     = (p => Math.Max(p.TotalMaximumLevels - p.FreeLevels, 0)),
                ValueUpdater     = (p, newRating) =>
                {
                    int delta = ((int)newRating) - p.Rating;
                    if (delta != 0)
                    {
                        p.Rating += delta;
                    }
                },
                MinExtractor = (p => 0),
                ValueGetter  = (p => p.Rating)
            })
            {
                Text   = "Rating",
                Tag    = "String_Rating",
                Sorter = (o1, o2) =>
                {
                    if (o1 is Power objPower1 && o2 is Power objPower2)
                    {
                        return(objPower1.Rating - objPower2.Rating);
                    }
                    string strMessage = "Can't sort an Object of Type " + o1.GetType() +
                                        " against another one of Type " + o2.GetType() + " in the ratingColumn." +
                                        Environment.NewLine + "Both objects SHOULD be of the type \"Power\".";
                    throw new ArgumentException(strMessage, nameof(o1));
                }
            };

            ratingColumn.AddDependency(nameof(Power.LevelsEnabled));
            ratingColumn.AddDependency(nameof(Power.FreeLevels));
            ratingColumn.AddDependency(nameof(Power.TotalMaximumLevels));
            ratingColumn.AddDependency(nameof(Power.TotalRating));
            TableColumn <Power> totalRatingColumn = new TableColumn <Power>(() => new TextTableCell())
            {
                Text      = "Total Rating",
                Extractor = (power => power.TotalRating),
                Tag       = "String_TotalRating",
                Sorter    = (o1, o2) =>
                {
                    if (o1 is Power objPower1 && o2 is Power objPower2)
                    {
                        return(objPower1.TotalRating - objPower2.TotalRating);
                    }
                    string strMessage = "Can't sort an Object of Type " + o1.GetType() +
                                        " against another one of Type " + o2.GetType() + " in the totalRatingColumn." +
                                        Environment.NewLine + "Both objects SHOULD be of the type \"Power\".";
                    throw new ArgumentException(strMessage, nameof(o1));
                }
            };

            totalRatingColumn.AddDependency(nameof(Power.TotalRating));

            TableColumn <Power> powerPointsColumn = new TableColumn <Power>(() => new TextTableCell())
            {
                Text             = "Power Points",
                Extractor        = (power => power.DisplayPoints),
                Tag              = "ColumnHeader_Power_Points",
                ToolTipExtractor = (item => item.ToolTip)
            };

            powerPointsColumn.AddDependency(nameof(Power.DisplayPoints));
            powerPointsColumn.AddDependency(nameof(Power.ToolTip));

            TableColumn <Power> sourceColumn = new TableColumn <Power>(() => new TextTableCell
            {
                Cursor = Cursors.Hand
            })
            {
                Text             = "Source",
                Extractor        = (power => power.SourceDetail),
                Tag              = "Label_Source",
                ToolTipExtractor = (item => item.SourceDetail.LanguageBookTooltip)
            };

            powerPointsColumn.AddDependency(nameof(Power.Source));

            TableColumn <Power> adeptWayColumn = new TableColumn <Power>(() => new CheckBoxTableCell <Power>
            {
                ValueGetter      = p => p.DiscountedAdeptWay,
                ValueUpdater     = (p, check) => p.DiscountedAdeptWay = check,
                VisibleExtractor = p => p.AdeptWayDiscountEnabled,
                EnabledExtractor = p => p.CharacterObject.AllowAdeptWayPowerDiscount || p.DiscountedAdeptWay,
                Alignment        = Alignment.Center
            })
            {
                Text = "Adept Way",
                Tag  = "Checkbox_Power_AdeptWay"
            };

            adeptWayColumn.AddDependency(nameof(Power.DiscountedAdeptWay));
            adeptWayColumn.AddDependency(nameof(Power.AdeptWayDiscountEnabled));
            adeptWayColumn.AddDependency(nameof(Character.AllowAdeptWayPowerDiscount));
            adeptWayColumn.AddDependency(nameof(Power.Rating));

            /*
             * TableColumn<Power> geasColumn = new TableColumn<Power>(() => new CheckBoxTableCell<Power>()
             * {
             *  ValueGetter = (p => p.DiscountedGeas),
             *  ValueUpdater = (p, check) => p.DiscountedGeas = check,
             *  Alignment = Alignment.Center
             * })
             * {
             *  Text = "Geas",
             *  Tag = "Checkbox_Power_Geas"
             * };
             * geasColumn.AddDependency(nameof(Power.DiscountedGeas));
             */

            TableColumn <Power> noteColumn = new TableColumn <Power>(() => new ButtonTableCell <Power>(new PictureBox
            {
                Image = Resources.note_edit,
                Size  = GetImageSize(Resources.note_edit)
            })
            {
                ClickHandler = async p =>
                {
                    using (EditNotes frmPowerNotes = new EditNotes(p.Notes, p.NotesColor))
                    {
                        await frmPowerNotes.ShowDialogSafeAsync(this);
                        if (frmPowerNotes.DialogResult == DialogResult.OK)
                        {
                            p.Notes = frmPowerNotes.Notes;
                        }
                    }
                },
                Alignment = Alignment.Center
            })
            {
                Text             = "Notes",
                Tag              = "ColumnHeader_Notes",
                ToolTipExtractor = (p =>
                {
                    string strTooltip = LanguageManager.GetString("Tip_Power_EditNotes");
                    if (!string.IsNullOrEmpty(p.Notes))
                    {
                        strTooltip += Environment.NewLine + Environment.NewLine + p.Notes.RtfToPlainText();
                    }
                    return(strTooltip.WordWrap());
                })
            };

            noteColumn.AddDependency(nameof(Power.Notes));

            TableColumn <Power> deleteColumn = new TableColumn <Power>(() => new ButtonTableCell <Power>(new Button
            {
                Text = LanguageManager.GetString("String_Delete"),
                Tag  = "String_Delete",
                Dock = DockStyle.Fill
            })
            {
                ClickHandler = p =>
                {
                    //Cache the parentform prior to deletion, otherwise the relationship is broken.
                    Form frmParent = ParentForm;
                    if (p.FreeLevels > 0)
                    {
                        string strExtra = p.Extra;
                        string strImprovementSourceName = ImprovementManager.GetCachedImprovementListForValueOf(p.CharacterObject, Improvement.ImprovementType.AdeptPowerFreePoints, p.Name)
                                                          .Find(x => x.UniqueName == strExtra)?.SourceName;
                        if (!string.IsNullOrWhiteSpace(strImprovementSourceName))
                        {
                            Gear objGear = p.CharacterObject.Gear.FindById(strImprovementSourceName);
                            if (objGear?.Bonded == true)
                            {
                                objGear.Equipped = false;
                                objGear.Extra    = string.Empty;
                            }
                        }
                    }
                    p.DeletePower();
                    p.UnbindPower();

                    if (frmParent is CharacterShared objParent)
                    {
                        objParent.IsCharacterUpdateRequested = true;
                    }
                    return(Task.CompletedTask);
                },
                EnabledExtractor = (p => p.FreeLevels == 0)
            });
コード例 #6
0
        public ActionResult EditNotes(int id, EditNotes notes)
        {
            var user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

            var sellnote = dobj.NoteDetail.Where(x => x.ID == id && x.IsActive == true && x.SellerID == user.ID).FirstOrDefault();

            if (sellnote == null)
            {
                return(HttpNotFound());
            }

            //if nnote is paid note
            if (notes.IsPaid == true && notes.NotesPreview == null && sellnote.NotesPreview == null)
            {
                ModelState.AddModelError("NotesPreview", "This field is required if selling type is paid");
                notes.NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList();
                notes.NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList();
                notes.CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList();
                return(View(notes));
            }

            if (ModelState.IsValid)
            {
                var notesattachement = dobj.NotesAttachments.Where(x => x.NoteID == notes.NoteID && x.IsActive == true).ToList();


                dobj.NoteDetail.Attach(sellnote);
                sellnote.Title          = notes.Title;
                sellnote.Category       = notes.Category;
                sellnote.NoteType       = notes.NoteType;
                sellnote.NumberofPages  = notes.NumberofPages;
                sellnote.Description    = notes.Description;
                sellnote.Country        = notes.Country;
                sellnote.UniversityName = notes.UniversityName;
                sellnote.Course         = notes.Course;
                sellnote.CourseCode     = notes.CourseCode;
                sellnote.Professor      = notes.Professor;
                if (notes.IsPaid == true)
                {
                    sellnote.IsPaid       = true;
                    sellnote.SellingPrice = notes.SellingPrice;
                }
                else
                {
                    sellnote.IsPaid       = false;
                    sellnote.SellingPrice = 0;
                }
                sellnote.ModifiedDate = DateTime.Now;
                sellnote.ModifiedBy   = user.ID;
                dobj.SaveChanges();

                if (notes.DisplayPicture != null)
                {
                    if (sellnote.DisplayPicture != null)
                    {
                        string   path = Server.MapPath(sellnote.DisplayPicture);
                        FileInfo file = new FileInfo(path);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                    }

                    string displaypicturefilename = System.IO.Path.GetFileName(notes.DisplayPicture.FileName);
                    string displaypicturepath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/";
                    NewDirectory(displaypicturepath);
                    string displaypicturefilepath = Path.Combine(Server.MapPath(displaypicturepath), displaypicturefilename);
                    sellnote.DisplayPicture = displaypicturepath + displaypicturefilename;
                    notes.DisplayPicture.SaveAs(displaypicturefilepath);
                    dobj.SaveChanges();
                }

                if (notes.NotesPreview != null)
                {
                    if (sellnote.NotesPreview != null)
                    {
                        string   path = Server.MapPath(sellnote.NotesPreview);
                        FileInfo file = new FileInfo(path);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                    }

                    string notespreviewfilename = System.IO.Path.GetFileName(notes.NotesPreview.FileName);
                    string notespreviewpath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/";
                    NewDirectory(notespreviewpath);
                    string notespreviewfilepath = Path.Combine(Server.MapPath(notespreviewpath), notespreviewfilename);
                    sellnote.NotesPreview = notespreviewpath + notespreviewfilename;
                    notes.NotesPreview.SaveAs(notespreviewfilepath);
                    dobj.SaveChanges();
                }

                dobj.NoteDetail.Attach(sellnote);
                dobj.Entry(sellnote).Property(x => x.DisplayPicture).IsModified = true;
                dobj.Entry(sellnote).Property(x => x.NotesPreview).IsModified   = true;
                dobj.SaveChanges();

                if (notes.UploadNotes[0] != null)
                {
                    string        path = Server.MapPath(notesattachement[0].FilePath);
                    DirectoryInfo dir  = new DirectoryInfo(path);
                    EmptyFolder(dir);


                    foreach (var item in notesattachement)
                    {
                        NotesAttachments attachement = dobj.NotesAttachments.Where(x => x.ID == item.ID).FirstOrDefault();
                        dobj.NotesAttachments.Remove(attachement);
                    }


                    foreach (HttpPostedFileBase file in notes.UploadNotes)
                    {
                        if (file != null)
                        {
                            string notesattachementfilename = System.IO.Path.GetFileName(file.FileName);
                            string notesattachementpath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/Attachements/";
                            NewDirectory(notesattachementpath);
                            string notesattachementfilepath = Path.Combine(Server.MapPath(notesattachementpath), notesattachementfilename);
                            file.SaveAs(notesattachementfilepath);


                            NotesAttachments notesattachements = new NotesAttachments
                            {
                                NoteID      = sellnote.ID,
                                FileName    = notesattachementfilename,
                                FilePath    = notesattachementpath,
                                CreatedDate = DateTime.Now,
                                CreatedBy   = user.ID,
                                IsActive    = true
                            };


                            dobj.NotesAttachments.Add(notesattachements);
                            dobj.SaveChanges();
                        }
                    }
                }

                return(RedirectToAction("Dashboard", "SellNotes"));
            }
            else
            {
                return(RedirectToAction("EditNotes", new { id = notes.ID }));
            }
        }