Example #1
0
        public ActionResult AddCategory(string name)
        {
            Category newCategory = new Category
            {
                Name        = name,
                CreatedDate = DateTime.Now,
            };

            db.Category.Add(newCategory);
            db.SaveChanges();

            return(View(newCategory));
        }
Example #2
0
        public ActionResult ChangePasswordd(string oldpassword, string newpassword, string confirmnewpassword)
        {
            var admin = db.Person.FirstOrDefault();

            if (oldpassword == admin.Password)
            {
                ViewBag.PreviousPassword = "******";
                if (newpassword != confirmnewpassword)
                {
                    TempData["Confirm"] = "Passwords are not the same!!!";
                    return(RedirectToAction("ChangePassword", "Admin"));
                }
                else
                {
                    admin.Password        = confirmnewpassword;
                    db.Entry(admin).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    TempData["Confirm"] = "You have already changed the password";

                    return(RedirectToAction("LoginPart", "Admin"));
                }
            }
            else
            {
                TempData["OldPassword"] = "******";
                return(RedirectToAction("ChangePassword", "Admin"));
            }
        }
        // GET: Admin/Contacts/Details/5
        public ActionResult Answer(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contact contact = db.Contact.Find(id);

            if (contact == null)
            {
                return(HttpNotFound());
            }

            if (!contact.isRead == true)
            {
                contact.isRead          = true;
                db.Entry(contact).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(contact, JsonRequestBehavior.AllowGet));
        }
        public void OnException(ExceptionContext filterContext)
        {
            var area = "";//todo....

            var controller = (filterContext.RouteData.Values["controller"] ?? "").ToString();
            var action     = (filterContext.RouteData.Values["action"] ?? "").ToString();

            //səbəbkar erroru tapmaq
            while (filterContext.Exception.InnerException != null)
            {
                filterContext.Exception = filterContext.Exception.InnerException;
            }

            var model = new HandleErrorInfo(filterContext.Exception, controller, action);

            try
            {
                using (var db = new myCvDbContext())
                {
                    var entity = new ErrorHistory();
                    if (!string.IsNullOrWhiteSpace(area))
                    {
                        entity.AreaName = area;
                    }
                    if (!string.IsNullOrWhiteSpace(controller))
                    {
                        entity.ControllerName = controller;
                    }
                    if (!string.IsNullOrWhiteSpace(action))
                    {
                        entity.ActionName = action;
                    }

                    if (filterContext.Exception is HttpException)
                    {
                        entity.ErrorCode = (filterContext.Exception as HttpException).GetHttpCode();
                    }
                    else if (filterContext.Exception is SqlException)
                    {
                        entity.ErrorCode    = (filterContext.Exception as SqlException).Number;
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    else
                    {
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    logger.Fatal(entity.ErrorMessage);
                    db.ErrorHistory.Add(entity);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //logger.Fatal(ex)
            }

            filterContext.Result = new ViewResult
            {
                ViewName = "~/Views/Home/ErrorHtml.cshtml",

                //MasterName = "~/Views/Shared/_Layout.cshtml",
                ViewData = new ViewDataDictionary <HandleErrorInfo>(model),
                TempData = filterContext.Controller.TempData
            };

            filterContext.ExceptionHandled = true;
        }
Example #5
0
        public ActionResult saveEditBioAndSkill(int?id, string yourdescription,
                                                int skilllevel, bool displayastag, bool displayasbar, string skilldescription,
                                                int?categorie, int?typeoffskills)
        {
            var skill    = db.Skills.Find(id);
            var category = db.Category.Find(categorie);
            var skillss  = db.TypeOfSkill.Find(typeoffskills);

            if (category == null || typeoffskills == null)
            {
                return(Json("nullCategoryAndSkill", JsonRequestBehavior.AllowGet));
            }
            skill.YourDescription  = yourdescription;
            skill.DisplayAsTag     = displayasbar;
            skill.DisplayAsTag     = displayastag;
            skill.SkillDescription = skilldescription;
            skill.Category         = category.Name;
            skill.SkillLevel       = skilllevel;
            skill.TypeOfSkill      = skillss.Name;
            skill.ModifiedDate     = DateTime.Now;
            db.Entry(skill).State  = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(PartialView("~/Areas/Admin/Views/Shared/PartialViews/BioAndSkillList.cshtml", db.Skills.Where(w => w.DeletedDate == null).ToList()));
        }