Exemple #1
0
        /// <summary>
        /// Cập nhật trạng thái từ vựng
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="State"></param>
        /// <param name="UpdateBy"></param>
        /// <returns></returns>
        public int UpdateState(int Id, int State, int UpdateBy)
        {
            DAL.tblWord word = (from w in Context.tblWords
                                where w.Id == Id
                                select w).FirstOrDefault();
            try
            {
                if (word != null)
                {
                    word.State       = State;
                    word.Update_By   = UpdateBy;
                    word.Update_Date = DateTime.Now;
                    Context.SubmitChanges();

                    string mess = "Xử lý cập nhật trạng thái từ vựng: " + Id.ToString() + " Bởi: " + UpdateBy.ToString();
                    Logs.LogWrite(mess, Configs.LOG_EVENT);
                    return(word.Id);
                }
                else
                {
                    return((int)EnumError.UPDATE_ERROR);
                }
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi cập nhật trạng thái: ";
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);

                return((int)EnumError.UPDATE_ERROR); // Trả về lỗi cập nhật.
            }
        }
Exemple #2
0
        /// <summary>
        /// Xử lý xóa từ vựng
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int Delete(int Id, int UpdateBy)
        {
            DAL.tblWord word = (from w in Context.tblWords
                                where w.Id == Id
                                select w).FirstOrDefault();
            try
            {
                if (word != null)
                {
                    word.Del_Flag = true;
                    word.Del_By   = UpdateBy;
                    Context.SubmitChanges();

                    string mess = "Xử lý xóa từ vựng: " + Id.ToString() + " Bởi: " + UpdateBy.ToString();
                    Logs.LogWrite(mess, Configs.LOG_EVENT);
                    return(word.Id);
                }
                else
                {
                    return((int)EnumError.DELETE_ERROR);
                }
            }
            catch (Exception ex)
            {
                string strErr = "Lỗi xóa từ vựng: ";
                strErr += "\\n" + ex.ToString();
                Logs.LogWrite(strErr);

                return((int)EnumError.DELETE_ERROR); // Trả về lỗi xóa.
            }
        }