Exemple #1
0
        public ActionResult Update(Publication publication)
        {
            List <MySqlParameter> parameters = new List <MySqlParameter>();
            string TimeOfViewParam           = "@tov";

            if (publication.TimeOfView > 0)
            {
                parameters.Add(new MySqlParameter("@tov", publication.TimeOfView));
            }
            else
            {
                TimeOfViewParam = "default";
            }

            if (publication.ExpiryDate < DateTime.Now.Date)
            {
                ViewBag.Status        = false;
                ViewBag.StatusMessage = "Please input Expiry Date.";
                return(View());
            }

            parameters.Add(new MySqlParameter("@expdate", publication.ExpiryDate));
            bool rlt = Mysqldb.Update($"update publications set TimeOfView={TimeOfViewParam}, ExpiryDate=@expdate where ID={publication.ID}", parameters);

            if (rlt)
            {
                ViewBag.Status        = true;
                ViewBag.StatusMessage = "Publication Updated Successfully.";
                TempData["ID"]        = publication.ID;
                PublicationsOnChange(publication.GetHashCode());
            }
            return(View(publication));
        }
Exemple #2
0
 private bool PublicationsOnChange(int ObjectHashCode)
 {
     using (SHA256 sha256 = SHA256.Create())
     {
         string hashedcode = Cryption.Encrypt(sha256, Convert.ToBase64String(BitConverter.GetBytes(ObjectHashCode)));
         return(Mysqldb.Update($"update tables_onchange set Value='{hashedcode}' where TableName='publications'"));
     }
 }