public ActionResult AddDetail(Person Person, HttpPostedFileBase Image) { if (db.Person.Any()) { var P = db.Person.FirstOrDefault(); P.Age = Person.Age; P.CareerLevel = Person.CareerLevel; P.Degree = Person.Degree; P.Email = Person.Email; P.Experience = Person.Experience; P.Fax = Person.Fax; P.Image = Person.Image; P.Location = Person.Location; P.Name = Person.Name; P.Phone = Person.Phone; P.Website = Person.Website; //db.Entry(P).State = System.Data.Entity.EntityState.Modified; string i = Image.SaveImage(Server.MapPath("~/Template/Media")); P.Image = i; P.UpdateDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("EditCV")); } if (ModelState.IsValid) { Person.CreatedDate = DateTime.Now; db.Person.Add(Person); db.SaveChanges(); } return(RedirectToAction("EditCV")); }
public ActionResult Create([Bind(Include = "Id,Name,CreatedDate,DeletedDate,UpdateDate")] Category category) { if (ModelState.IsValid) { db.Category.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "Id,Name,CreatedDate,DeletedDate,UpdateDate")] Skills skills) { if (ModelState.IsValid) { db.Skills.Add(skills); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(skills)); }
/// <summary> /// Действие при выборе/снятия выбора с мультсериала /// </summary> public void CheckedValidation() { if (CvDbContext.ChangeTracker.HasChanges()) { CvDbContext.SaveChanges(); } CheckedEpisodes = new List <CartoonEpisode>( CvDbContext.CartoonEpisodes .Include(ce => ce.CartoonVoiceOver) .Include(ce => ce.CartoonSeason) .Include(ce => ce.EpisodeOptions) .Include(ce => ce.Cartoon) .Where(ce => ce.Cartoon.Checked && ce.CartoonSeason.Checked && ce.Checked)); if (CheckedEpisodes.Count > 0) { FilterCheckedEpisodes(); } GeneralSettings.AvailableEpisodesCount = CheckedEpisodes.Count; WriteClassInFile(GeneralSettings, SavedGeneralSettingsFileName, GeneralSettingsFileExtension, AppDataPath); NotifyOfPropertyChange(() => GeneralSettings); NotifyOfPropertyChange(() => CanStart); }
public void VoiceOverCheck() { CvDbContext.ChangeTracker.DetectChanges(); if (CvDbContext.ChangeTracker.HasChanges()) { CvDbContext.SaveChanges(); } }
public void EpisodeCheckValidation() { CvDbContext.ChangeTracker.DetectChanges(); if (CvDbContext.ChangeTracker.HasChanges()) { CvDbContext.SaveChanges(); } }
private void PlayEpisode(CartoonEpisode episode) { var cartUrl = episode.Cartoon.CartoonUrls.First(cu => cu.Checked); var webSite = CvDbContext.CartoonWebSites .Include(cws => cws.ElementValues) .First(cws => cws.CartoonWebSiteId == cartUrl.CartoonWebSiteId); var urlString = $"{cartUrl.Url}{episode.FullNumber}/{episode.CartoonVoiceOver.UrlParameter}"; var elementValue = webSite.ElementValues.First(); CurrentOptionId = episode.EpisodeOptions .First(eo => eo.CartoonEpisodeId == episode.CartoonEpisodeId && eo.CartoonVoiceOverId == episode.CartoonVoiceOver.CartoonVoiceOverId).EpisodeOptionId; //Попытки перейти на указанный url при нестабильном интернет соединении for (var i = 0; i < 10; i++) { try { Helper.Browser.Navigate().GoToUrl(urlString); break; } catch { Helper.Browser.Navigate().Refresh(); } } var option = CvDbContext.EpisodeOptions .Include(eo => eo.Jumpers) .First(eo => eo.EpisodeOptionId == CurrentOptionId); CurrentDuration = option.Duration; option.LastDateViewed = DateTime.Now; CvDbContext.SaveChanges(); Jumpers = new List <Jumper>(option.Jumpers); CurrentJumper = Jumpers[jumperCount++]; WebElement = Helper.Browser.FindElement(By.CssSelector(elementValue.CssSelector)); StartVideoPlayer(); Helper.Timer.Restart(); LaunchMonitoring(); if (GeneralSettings.WatchingInRow) { GeneralSettings.LastWatchedEpisodeInRowFullNumber = episode.FullNumber; WriteClassInFile(GeneralSettings, SavedGeneralSettingsFileName, GeneralSettingsFileExtension, AppDataPath); } }
// GET: Ad1000/ContactMe/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ContactMe contactMe = db.ContactMe.Find(id); contactMe.IsRead = true; db.SaveChanges(); if (contactMe == null) { return(HttpNotFound()); } if (Request.IsAjaxRequest()) { var c = db.ContactMe.Find(id); return(PartialView("~/Areas/Ad1000/Views/ContactMe/ContactReply.cshtml", c)); } return(View(contactMe)); }
public ActionResult Contact(ContactMe emailModel) { if (emailModel.Name == null || emailModel.Email == null || emailModel.Content == null) { TempData["fill"] = "Name,Email,and Body must be written"; return(RedirectToAction("Contact")); } if (ModelState.IsValid) { db.ContactMe.Add(emailModel); db.SaveChanges(); Extension.SendMail(emailModel.Subject, emailModel.Content, emailModel.Email); return(RedirectToAction("Contact")); } return(RedirectToAction("Contact")); }
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 CvDbContext()) { 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.CreatedDate = DateTime.Now; db.ErrorHistories.Add(entity); db.SaveChanges(); } } catch (Exception) { //logger.Fatal(ex) } filterContext.Result = new ViewResult { ViewName = "~/Views/Home/ErrorPage.cshtml", //MasterName = "~/Views/Shared/_Layout.cshtml", ViewData = new ViewDataDictionary <HandleErrorInfo>(model), TempData = filterContext.Controller.TempData }; filterContext.ExceptionHandled = true; }