Example #1
0
        public void QnoteListView_UpdateItem(QnoteCollectionID qnoteCollectionID)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (qnoteCollectionID.NoteID <= 0)
                    {
                        // Checks if the note exists, else we wont be able to update it, right!?
                        ModelState.AddModelError("", String.Format("Anteckningen med det angivna id:t {0} existerar inte!", qnoteCollectionID.NoteID));
                        return;
                    }
                    else
                    {
                        DropDownList ddlCollection = QnoteUpdateFormView.FindControl("DropDownListCollection") as DropDownList;
                        qnoteCollectionID.CollectionNameID = Int32.Parse(ddlCollection.SelectedValue.ToString());

                        // Updates the note, and shows that all worked out!
                        Service.CreateNoteAndCollection(qnoteCollectionID);
                        Session["Success"] = "Anteckningen har uppdaterats!";
                        Response.RedirectToRoute("SingleNote", new { id = qnoteCollectionID.NoteID, header = qnoteCollectionID.Header });
                        Context.ApplicationInstance.CompleteRequest();
                    }
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Ett fel inträffade då anteckningen skulle uppdateras, försök igen om en stund!");
                }
            }
        }
Example #2
0
        // Creates or updates a note.
        public void CreateNoteAndCollection(QnoteCollectionID qnoteCollectionID)
        {
            ICollection<ValidationResult> validationResults;
            if (!qnoteCollectionID.Validate(out validationResults))
            {
                var ex = new ValidationException("The Qnote object did not pass the data validation!");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }

            if (qnoteCollectionID.NoteID == 0)
            {
                NoteDAL.CreateNoteAndCollection(qnoteCollectionID);
            }
            else
            {
                NoteDAL.UpdateNoteAndCollection(qnoteCollectionID);
            }
        }
Example #3
0
        // Creates or updates a note.
        public void CreateNoteAndCollection(QnoteCollectionID qnoteCollectionID)
        {
            ICollection<ValidationResult> validationResults;
            if (!qnoteCollectionID.Validate(out validationResults))
            {
                var ex = new ValidationException("The Qnote object did not pass the data validation!");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }

            if (qnoteCollectionID.NoteID == 0)
            {
                NoteDAL.CreateNoteAndCollection(qnoteCollectionID);
            }
            else
            {
                NoteDAL.UpdateNoteAndCollection(qnoteCollectionID);
            }
        }