Пример #1
0
        // GET: Admin/EmailModel/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmailModel emailModel = db.EmailModel.Find(id);

            if (emailModel == null)
            {
                if (Request.IsAjaxRequest())
                {
                    return(Content(""));
                }
                return(HttpNotFound());
            }
            if (Request.IsAjaxRequest())
            {
                emailModel.IsRead = true;
                db.SaveChanges();
                return(PartialView("~/Areas/Admin/Views/EmailModel/Partial/_PartialList.cshtml", emailModel));
            }
            emailModel.IsRead          = true;
            db.Entry(emailModel).State = EntityState.Modified;
            db.SaveChanges();
            return(View(emailModel));
        }
Пример #2
0
 public ActionResult Create([Bind(Include = "Id,Name,CreationDate,CreatedId,ModifiedDate,ModifiedId,DeletedDate,DeletedId")] Skill skill)
 {
     if (ModelState.IsValid)
     {
         skill.CreationDate = DateTime.UtcNow;
         db.Skill.Add(skill);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skill));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "Id,Name,CreationDate,CreatedId,ModifiedDate,ModifiedId,DeletedDate,DeletedId")] Category category)
        {
            if (ModelState.IsValid)
            {
                category.CreationDate = DateTime.UtcNow;
                db.Category.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #4
0
 public ActionResult Contact(EmailModel emailModel)
 {
     if (emailModel.Name == null || emailModel.UserEmail == null || emailModel.Body == null || emailModel.Subject == null)
     {
         TempData["fill"] = "All inputs must be written";
         return(RedirectToAction("Contact"));
     }
     if (ModelState.IsValid)
     {
         db.EmailModel.Add(emailModel);
         db.SaveChanges();
         emailModel.ToMails.SendMail(emailModel.Subject, emailModel.Body);
         return(RedirectToAction("Contact"));
     }
     return(RedirectToAction("Contact"));
 }
        //Logger logger;
        //public OnlineExceptionFilterAttribute(Logger logger)
        //{
        //    this.logger = logger;
        //}
        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 OnlineCvDbContext())
                {
                    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);
                    entity.CreationDate = DateTime.UtcNow;
                    db.ErrorHistory.Add(entity);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                logger.Fatal(ex);
            }

            filterContext.Result = new ViewResult
            {
                ViewName = "~/Views/Shared/Error.cshtml",
                //MasterName = "~/Areas/Admin/Views/Shared/_Layout.cshtml",
                ViewData = new ViewDataDictionary <HandleErrorInfo>(model),
                TempData = filterContext.Controller.TempData
            };

            filterContext.ExceptionHandled = true;
        }
Пример #6
0
        public ActionResult addInfos(PersonDetails postPerson, HttpPostedFileBase mediaUrl, string fileName)
        {
            if (mediaUrl != null)
            {
                bool valid = true;
                if (!mediaUrl.CheckImageType())
                {
                    ModelState.AddModelError("mediaUrl", "Şəkil uyğun deyil!");
                    valid = false;
                }

                if (!mediaUrl.CheckImageSize(5))
                {
                    ModelState.AddModelError("mediaUrl", "Şəklin ölçüsü uyğun deyil!");
                    valid = false;
                }

                if (valid)
                {
                    string newPath = mediaUrl.SaveImage(Server.MapPath("~/Template/media"));

                    //System.IO.File.Move(Server.MapPath(System.IO.Path.Combine("~/Template/media", entity.MediaUrl)),
                    //    Server.MapPath(System.IO.Path.Combine("~/Template/media", entity.MediaUrl)));
                    postPerson.MediaUrl = newPath;
                }
            }
            else if (string.IsNullOrWhiteSpace(postPerson.MediaUrl))
            {
                postPerson.MediaUrl = null;
            }


            var personExists = db.PersonDetails.Any();
            var person       = db.PersonDetails.FirstOrDefault();

            if (personExists)
            {
                if (ModelState.IsValid)
                {
                    person.Age          = postPerson.Age;
                    person.CareerLevel  = postPerson.CareerLevel;
                    person.Degree       = postPerson.Degree;
                    person.Email        = postPerson.Email;
                    person.Experience   = postPerson.Experience;
                    person.Fax          = postPerson.Fax;
                    person.Location     = postPerson.Location;
                    person.MediaUrl     = postPerson.MediaUrl;
                    person.Name         = postPerson.Name;
                    person.Phone        = postPerson.Phone;
                    person.Website      = postPerson.Website;
                    person.ModifiedDate = DateTime.UtcNow;
                    person.MediaUrl     = postPerson.MediaUrl;
                    db.SaveChanges();
                    return(PartialView("EditCV"));
                }
            }
            if (ModelState.IsValid)
            {
                postPerson.MediaUrl     = mediaUrl.SaveImage(Server.MapPath("~/Template/media"));
                postPerson.CreationDate = DateTime.UtcNow;
                db.PersonDetails.Add(postPerson);
                db.SaveChanges();
            }
            return(View("EditCV"));
        }