public bool UpdateHeaderTemplate(HeaderTemplate headerTemplate)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    var template = db.HeaderTemplates.Where(d => d.ID == headerTemplate.ID).FirstOrDefault();
                    if (template == null)
                    {
                        return(false);
                    }

                    template.Content           = headerTemplate.Content;
                    template.ContentEnglish    = headerTemplate.ContentEnglish;
                    template.IsDefaultTemplate = headerTemplate.IsDefaultTemplate;
                    template.LastUpdate        = DateTime.Now;

                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(false);
        }
Example #2
0
        public ResponseModel Update(QuestionKit model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    var questionKit = db.QuestionKits.Where(d => d.ID == model.ID).FirstOrDefault();
                    if (questionKit == null)
                    {
                        return(result);
                    }

                    questionKit.Name        = model.Name;
                    questionKit.Description = model.Description;
                    questionKit.LastUpdate  = DateTime.Now;

                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }

            return(result);
        }
Example #3
0
        public ResponseModel Update(Question model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    var question = db.Questions.Where(d => d.ID == model.ID).FirstOrDefault();
                    if (question == null)
                    {
                        return(result);
                    }

                    question.QuestionString  = model.QuestionString;
                    question.SelectedAnswers = model.SelectedAnswers;
                    question.Answer          = model.Answer;
                    question.LastUpdate      = DateTime.Now;

                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }

            return(result);
        }
Example #4
0
        public bool UpdatePage(Page page)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    var pageData = db.Pages.Where(d => d.ID == page.ID).FirstOrDefault();
                    if (pageData == null)
                    {
                        return(false);
                    }


                    pageData.Title       = page.Title;
                    pageData.FriendlyUrl = page.FriendlyUrl;
                    pageData.Status      = page.Status;
                    pageData.Content     = page.Content;
                    pageData.IsHomePage  = page.IsHomePage;

                    pageData.TitleEnglish       = page.TitleEnglish;
                    pageData.FriendlyUrlEnglish = page.FriendlyUrlEnglish;
                    pageData.ContentEnglish     = page.ContentEnglish;

                    pageData.FooterTemplateId = page.FooterTemplateId;
                    pageData.HeaderTemplateId = page.HeaderTemplateId;
                    pageData.LastUpdateBy     = page.LastUpdateBy;
                    pageData.LastUpdate       = DateTime.Now;
                    pageData.RecordOrder      = page.RecordOrder;
                    pageData.RecordActive     = page.RecordActive;
                    pageData.RecordDeleted    = page.RecordDeleted;

                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(false);
        }
Example #5
0
        public int SaveFormData(Form form)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    db.Forms.Add(form);
                    return(db.SaveChanges());
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(0);
        }
Example #6
0
        public int CreateEmailAsync(EmailQueue newEmail)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    db.EmailQueues.Add(newEmail);
                    return(db.SaveChanges());
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(0);
        }
Example #7
0
        //private readonly KentEntities kentEntities;
        //public EmailQueueRepository()
        //{
        //    kentEntities = new KentEntities();
        //}

        public bool SaveEmailToQueue(EmailQueue email)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    db.EmailQueues.Add(email);
                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(false);
        }
        public bool AddHeaderTemplate(HeaderTemplate headerTemplate)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    db.HeaderTemplates.Add(headerTemplate);
                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }


            return(false);
        }
Example #9
0
        public bool AddPage(Page page)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    db.Pages.Add(page);
                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }


            return(false);
        }
Example #10
0
        public bool UpdateLastLoginTime(int userId)
        {
            using (var db = new KentEntities())
            {
                try
                {
                    var user = db.Users.Where(d => d.UserTypeId == userId).FirstOrDefault();
                    user.LastLogin = DateTime.Now;

                    return(db.SaveChanges() > 0 ? true : false);
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
            }

            return(false);
        }
Example #11
0
        public ResponseModel Update(Menu model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    var menu = db.Menus.Where(d => d.ID == model.ID).FirstOrDefault();
                    if (menu == null)
                    {
                        return(result);
                    }

                    menu.Name       = model.Name;
                    menu.Action     = model.Action;
                    menu.Controller = model.Controller;
                    menu.Area       = model.Area;
                    menu.Visible    = model.Visible;
                    menu.LastUpdate = DateTime.Now;

                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }

            return(result);
        }
Example #12
0
        public ResponseModel Insert(QuestionKit model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    db.QuestionKits.Add(model);
                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }
            return(result);
        }