Ejemplo n.º 1
0
        /// <summary>
        /// Sets data for edit mode
        /// </summary>
        /// <param name="edited">edited entity</param>
        public void setEditData(author edited)
        {
            _action = new CMS_Action("/backend/EditAuthor?uid=" + edited.usersid.ToString());

            _elements["lastname"].setValue(edited.lastname);
            _elements["name"].setValue(edited.name);
            _elements["description"].setValue(edited.description);

            _elements["ok"].setLabel("Save changes");
        }
Ejemplo n.º 2
0
 partial void Deleteauthor(author instance);
Ejemplo n.º 3
0
 partial void Updateauthor(author instance);
Ejemplo n.º 4
0
 partial void Insertauthor(author instance);
Ejemplo n.º 5
0
        /// <summary>
        /// Save changes to the given author
        /// </summary>
        /// <param name="form">Author data</param>
        /// <param name="edited">Edited author</param>
        /// <returns>success</returns>
        public bool saveAuthor(Form_Author_Add form, author edited)
        {
            author toSave = new author();
            toSave.id = edited.id;
            toSave.lastname = form["lastname"].getValue();
            toSave.description = form["description"].getValue();
            toSave.name = form["name"].getValue();
            toSave.usersid = edited.usersid;
            toSave.date = edited.date;

            using (LangDataContext a = new LangDataContext())
            {
                a.authors.Attach(toSave, edited);
                try
                {
                    a.SubmitChanges();
                }
                catch (Exception)
                {
                    return false;
                }

                return true;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds an author to the system
        /// </summary>
        /// <param name="form">Author data</param>
        /// <param name="id">User id</param>
        /// <returns>success</returns>
        public bool promoteUser(Form_Author_Add form, long id)
        {
            using (LangDataContext a = new LangDataContext())
            {
                author toSave = new author();
                toSave.date = DateTime.Now;
                toSave.description = form["description"].getValue();
                toSave.lastname = form["lastname"].getValue();
                toSave.name = form["name"].getValue();
                toSave.usersid = id;

                a.authors.InsertOnSubmit(toSave);
                try
                {
                    a.SubmitChanges();
                }
                catch(Exception e)
                {
                    CMS.Services.CMS_Services_Message.getInstance().addError(e.Message);
                    return false;
                }
            }

            return true;
        }