public ActionResult Edit(EditModel model) { if (!ModelState.IsValid) return View(model); var entry = Services.Entry.GetBySlug(model.Slug); entry.Title = model.Title; entry.DateCreated = DateTime.Parse(model.Date); entry.Markdown = model.Markdown; var slugChanged = !string.Equals(model.Slug, model.NewSlug, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(model.NewSlug); if (slugChanged) { if (Services.Entry.Exists(model.NewSlug)) { ModelState.AddModelError("NewSlug", "Sorry, a post with that slug already exists."); return View(model); } Services.Entry.Delete(model.Slug); entry.Slug = model.NewSlug; } Services.Entry.Save(entry); return RedirectToAction("Show", "Entry", new { id = entry.Slug }); }
public ActionResult Add(EditModel model) { var slug = model.Title.ToUrlSlug(); // (these fields are hidden when creating a new entry, so don't validate them) ModelState["NewSlug"].Errors.Clear(); ModelState["Date"].Errors.Clear(); if (Services.Entry.Exists(slug)) ModelState.AddModelError("Title", "Sorry, a post already exists with the slug '" + slug + "', please change the title."); if (!ModelState.IsValid) return View("Edit", model); var entry = new Entry { Title = model.Title, Markdown = model.Markdown, Slug = slug, Author = Services.User.Current.FriendlyName, DateCreated = DateTime.Now, IsPublished = false }; Services.Entry.Save(entry); return RedirectToAction("Show", "Entry", new { id = entry.Slug }); }
public ActionResult Edit(EditModel model) { if (!ModelState.IsValid) { return View(model); } // Get the About entity if it exists, so ImageUrl doesn't get overriden to null if no image is selected and user is saving in json instead of sql. var about = Services.About.Exists(model.Title) ? Services.About.GetByTitle(model.Title) : new About(); about.Name = model.Name; about.Title = model.Title; about.Content = model.Content; // Save the image in blob storage if (model.Image != null) { var image = new NBlog.Web.Application.Service.Entity.Image(); var fileName = Path.GetFileName(model.Image.FileName); // Scale the image before saving using (var scaledImageStream = new MemoryStream()) { var settings = new ResizeSettings(200, 150, FitMode.None, "jpg"); ImageBuilder.Current.Build(model.Image.InputStream, scaledImageStream, settings); image.StreamToUpload = scaledImageStream; // Set FileName to save as, gets read as a repository key image.FileName = fileName; Services.Image.Save(image); } // Get the url to link to the About Entity about.ImageUrl = Services.Image.GetByFileName(fileName).Uri; } Services.About.Save(about); return RedirectToAction("Index", "About"); }
public ActionResult Edit(Guid?id, Guid?componentId) { var model = new EditModel(); model.Load(id, componentId); model.LoadRule(); return(View(model)); }
public ActionResult Revert(string id) { EditModel.Revert(new Guid(id)); SuccessMessage(Piranha.Resources.Post.MessageReverted); return(Edit(id)); }
public ActionResult Save(EditModel model) { if (ModelState.IsValid) { model.Save(api); return JsonData(true, model); } return JsonData(false); }
public ActionResult Show(Guid id) { var model = new EditModel(); model.Load(id, null); model.LoadRule(); return(View(model)); }
public IActionResult Store(EditModel model) { try{ DateTime storeDate = DateTime.Now; string reg = model.Aircraft.RegistrationNumber; var origin = _context.Aircraft.AsNoTracking().Where(a => a.RegistrationNumber == reg).FirstOrDefault(); if (!model.NotUpdateDate || model.IsNew) { model.Aircraft.UpdateTime = storeDate; } model.Aircraft.ActualUpdateTime = storeDate; if (model.IsNew) { model.Aircraft.CreationTime = storeDate; _context.Aircraft.Add(model.Aircraft); } else { if (!model.NotUpdateDate) { //Historyにコピー var ah = new AircraftHistory(); Mapper.Map(origin, ah); ah.HistoryRegisterAt = storeDate; //HistoryのSEQのMAXを取得 var maxseq = _context.AircraftHistory.AsNoTracking().Where(ahh => ahh.RegistrationNumber == ah.RegistrationNumber).GroupBy(ahh => ahh.RegistrationNumber) .Select(ahh => new { maxseq = ahh.Max(x => x.Seq) }).FirstOrDefault(); ah.Seq = (maxseq?.maxseq ?? 0) + 1; _context.AircraftHistory.Add(ah); } _context.Entry(model.Aircraft).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } //デリバリーされたらテストレジはクリア if (!OperationCode.PRE_DELIVERY.Contains(model.Aircraft.OperationCode)) { model.Aircraft.TestRegistration = null; } _context.SaveChanges(); }catch (Exception ex) { model.ex = ex; } model.AirlineList = MasterManager.AllAirline; model.TypeList = MasterManager.Type; model.OperationList = MasterManager.Operation; model.WiFiList = MasterManager.Wifi; string noheadString = string.Empty; if (model.NoHead) { noheadString = "?nohead=" + model.NoHead.ToString(); } //写真を更新 _ = HttpClientManager.GetInstance().GetStringAsync($"http://localhost:5000/Aircraft/Photo/{model.Aircraft.RegistrationNumber}?force=true"); return(Redirect("/E/" + model.Aircraft.RegistrationNumber + noheadString)); }
public async Task <ActionResult> RecoveryCodes_Partial(EditModel model) { using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) { UserDefinition user = await userDP.GetItemByUserIdAsync(Manager.UserId); if (user == null) { throw new InternalError("User with id {0} not found", Manager.UserId); } EditModel.ModelProgressEnum progress = (EditModel.ModelProgressEnum)Manager.SessionSettings.SiteSettings.GetValue <int>(IDENTITY_RECOVERY_PROGRESS, (int)EditModel.ModelProgressEnum.New); model.ModelProgress = progress; model.UpdateData(user); if (!ModelState.IsValid) { return(PartialView(model)); } string msg = null; switch (progress) { case EditModel.ModelProgressEnum.New: progress = EditModel.ModelProgressEnum.ShowLogin; break; case EditModel.ModelProgressEnum.ShowLogin: #if MVC6 if (!await Managers.GetUserManager().CheckPasswordAsync(user, model.Password)) #else if (await Managers.GetUserManager().FindAsync(user.UserName, model.Password) == null) #endif { ModelState.AddModelError(nameof(model.Password), this.__ResStr("badPassword", "The password is invalid")); } if (!ModelState.IsValid) { return(PartialView(model)); } progress = EditModel.ModelProgressEnum.ShowCodes; break; case EditModel.ModelProgressEnum.ShowCodes: await GenerateRecoveryCodeAsync(userDP, user); msg = this.__ResStr("newCode", "A new recovery code has been generated"); break; } Manager.SessionSettings.SiteSettings.SetValue <int>(IDENTITY_RECOVERY_PROGRESS, (int)progress); Manager.SessionSettings.SiteSettings.Save(); model.ModelProgress = progress; model.UpdateData(user); return(FormProcessed(model, popupText: msg, ForceApply: true)); } }
public ActionResult ConfirmRemoval(string siteDomain) { EditModel model = new EditModel { }; model.SiteDomainDisplay = siteDomain; model.SiteDomain = siteDomain; return(View(model)); }
/// <summary> /// 编辑属性值 /// </summary> /// <returns></returns> public ActionResult AttrValueEdit(string act = "", int id = 0, int aId = 0, int storeId = 0, DishAttr model = null, int fid = 0) { //参数验证 if (id < 0 || aId <= 0 || storeId <= 0) { _result.msg = "参数错误"; return(Json(_result)); } //显示 if (string.IsNullOrEmpty(act)) { if (id == 0) { model = new DishAttr(); } else { model = DishAttrBLL.SingleModel.GetModel(id); if (model == null) { return(Content("分类不存在")); } } EditModel <DishAttr> em = new EditModel <DishAttr>(); em.DataModel = model; em.aId = aId; em.storeId = storeId; ViewBag.dishAttrTypeList = DishAttrTypeBLL.SingleModel.GetList($"state=1 and aid={aId} and storeId={storeId}"); ViewBag.fid = fid; return(View(em)); } else { if (act == "edit") { //去除首位多余的换行,保证两个值之间只有一个换行 if (model != null && !string.IsNullOrEmpty(model.attr_values)) { model.attr_values = string.Join("\n", model.attr_values.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Distinct()); } if (id == 0) { int newid = Convert.ToInt32(DishAttrBLL.SingleModel.Add(model)); _result.msg = newid > 0 ? "添加成功" : "添加失败"; _result.code = newid > 0 ? 1 : 0; } else { bool updateResult = DishAttrBLL.SingleModel.Update(model); _result.msg = updateResult ? "修改成功" : "修改失败"; _result.code = updateResult ? 1 : 0; } } } return(Json(_result)); }
public ActionResult TemplateModuleSelection() { EditModel model = new EditModel { ROModule = Module.PermanentGuid,// use this module as displayed module ROModuleNew = Module.PermanentGuid, }; return(View(model)); }
public async Task <IActionResult> ChangeName(EditModel model) { var id = model.TaskGroup.Id; var name = model.TaskGroup.Name; await _taskGroupService.UpdateAsync(id, name); return(RedirectToAction("Edit", "TaskGroup", new { groupId = id })); }
protected override void Because_of() { testEntity = new Entity { Value1 = 1, Value2 = 2, }; testModel = Mapper.Map <Entity, EditModel>(testEntity); }
public void UpdatePage(EditModel model) { var page = db.Pages.Where(p => p.PageId == model.Id).FirstOrDefault(); page.Title = model.Title; page.Content = model.pageContent; UpdateTags(model.Id, model.Tags); db.SaveChanges(); }
public ActionResult BasicTemplates_Partial(EditModel model) { model.UpdateData(Module); if (!ModelState.IsValid) { return(PartialView(model)); } return(FormProcessed(model, this.__ResStr("ok", "OK"), OnPopupClose: OnPopupCloseEnum.ReloadModule)); }
protected override void Because_of() { testEntity = new Entity { Value1 = 1, Value2 = 2, }; testModel = Mapper.Map<Entity, EditModel>(testEntity); }
public async Task <IActionResult> Edit(EditModel model) { //dohvatam ulogovanog usera i njega prosledjujem cisto zbog imena i prezimena User user = await this.userManager.GetUserAsync(base.User); model.firstName = user.firstName; model.lastName = user.lastName; return(View(model)); }
public IActionResult Submit(int id, EditModel model) { ModelState.Clear(); model.HasChanges = true; // Handle update of Domain, resulting in new list of cultures! return(EditView(model)); }
public async Task <ActionResult> SelectTwoStepSetup() { EditModel model = new EditModel(); Manager.NeedUser(); using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) { UserDefinition user = await userDP.GetItemByUserIdAsync(Manager.UserId); if (user == null) { throw new InternalError("User with id {0} not found", Manager.UserId); } using (UserLoginInfoDataProvider logInfoDP = new UserLoginInfoDataProvider()) { string ext = await logInfoDP.GetExternalLoginProviderAsync(Manager.UserId); if (ext != null) { return(View("ShowMessage", this.__ResStr("extUser", "Your account uses a {0} account - Two-step authentication must be set up using your {0} account.", ext), UseAreaViewName: false)); } } TwoStepAuth twoStep = new TwoStepAuth(); List <ITwoStepAuth> list = await twoStep.GetTwoStepAuthProcessorsAsync(); List <string> procs = (from p in list select p.Name).ToList(); List <string> enabledTwoStepAuths = (from e in user.EnabledTwoStepAuthentications select e.Name).ToList(); foreach (string proc in procs) { ITwoStepAuth auth = await twoStep.GetTwoStepAuthProcessorByNameAsync(proc); if (auth != null) { ModuleAction action = await auth.GetSetupActionAsync(); if (action != null) { string status; if (enabledTwoStepAuths.Contains(auth.Name)) { status = this.__ResStr("enabled", "(Enabled)"); } else { status = this.__ResStr("notEnabled", "(Not Enabled)"); } model.AuthMethods.Add(new Controllers.SelectTwoStepSetupModuleController.EditModel.AuthMethod { Action = action, Status = status, Description = auth.GetDescription() }); } } } model.AuthMethods = (from a in model.AuthMethods orderby a.Action.LinkText select a).ToList(); } return(View(model)); }
public void EditNote(EditModel data) { var storedData = _noteRepository.GetSingle(data.Id); storedData.Title = data.Title; storedData.Description = data.Description; storedData.Timestamp = data.Timestamp; _noteRepository.Edit(storedData); _uow.SaveChanges(); }
public ActionResult TemplateModuleSelection_Partial(EditModel model) { model.ROModule = Module.PermanentGuid; model.ROModuleNew = Module.PermanentGuid; if (!ModelState.IsValid) { return(PartialView(model)); } return(FormProcessed(model, this.__ResStr("ok", "OK"))); }
/// <summary> /// Try to get this month's report if it exists /// </summary> public async Task <IActionResult> Editor([FromServices] AppDbContextFactory factory, long flatId) { var model = new EditModel(); using (var context = factory.CreateContext()) { await model.TryLoadAsync(context, flatId); } return(View(model)); }
public async Task OnGet_MissingId_ReturnsNotFound() { var mockRepo = new Mock <IUserService>(); var pageModel = new EditModel(mockRepo.Object); var result = await pageModel.OnGetAsync(null).ConfigureAwait(false); result.Should().BeOfType <NotFoundResult>(); pageModel.UserId.Should().Be(Guid.Empty); }
public async Task <ActionResult> TinyLanguage_Partial(EditModel model) { if (!ModelState.IsValid) { return(PartialView(model)); } await Manager.SetUserLanguageAsync(model.LanguageId); return(Redirect(Manager.ReturnToUrl, ForceRedirect: true)); }
public ActionResult Edit(int id) { var request = PendingRequests.First(pr => pr.Id == id); // no error handling! var model = new EditModel { PendingRequest = request }; return(View(model)); }
public ActionResult Edit(string empid, string empname) { EditModel editModel = new EditModel { ID = empid, NAME = empname }; return(View(editModel)); }
public ActionResult Edit(Guid id) { var model = EditModel.GetById(api, id); ViewBag.Title = Piranha.Manager.Resources.Post.EditTitle; ViewBag.SubTitle = model.Published.HasValue ? ((model.Published.Value > DateTime.Now ? "Schedueled: " : "Published: ") + model.Published.Value.ToString("yyyy-MM-dd")) : "Unpublished"; return(View(model)); }
public ActionResult Edit(EditModel model) { setViewData(model.Id); GeoConfigHelper configHelper = new GeoConfigHelper(); configHelper.Save(model); return(PartialView("_view", model)); }
public ActionResult Save(EditModel model) { if (ModelState.IsValid) { model.Save(api); return(JsonData(true, model)); } return(JsonData(false)); }
public ActionResult SaveComments(EditModel.CommentModel model) { Piranha.Config.Comments.ModerateAnonymous = model.ModerateAnonymous; Piranha.Config.Comments.ModerateAuthorized = model.ModerateAuthorized; Piranha.Config.Comments.NotifyAuthor = model.NotifyAuthor; Piranha.Config.Comments.NotifyModerators = model.NotifyModerators; Piranha.Config.Comments.Moderators = model.Moderators; return(JsonData(true, EditModel.Get(api))); }
public IActionResult New(int?domainId) { var model = new EditModel(); model.Item = new Data.Localize.Key() { DomainId = domainId ?? 0 }; return(EditView(model)); }
public ActionResult Edit(EditInputModel input) { var book = BookStore.GetBook(input.Book); var category = book.GetCategory(input.Category); var word = category.GetWord(input.Word); var model = new EditModel(word); return(View(model)); }
public async Task <ActionResult> ProfileEdit_Partial(EditModel model) { using (UserInfoDataProvider userInfoDP = new UserInfoDataProvider()) { Manager.NeedUser(); bool newUser = false; UserInfo userInfo = await userInfoDP.GetItemAsync(model.UserId); if (userInfo == null) { newUser = true; userInfo = new UserInfo(); } model.UpdateData(userInfo); // in case of apply, we're just updating the form with new fields - we chose a postback when switching // the country as potentially many different address formats could be supported which could overwhelm client side processing // so we only provide the fields for one country to the form. if (IsApply) { ModelState.Clear(); return(PartialView(model)); } if (!ModelState.IsValid) { return(PartialView(model)); } userInfo = model.GetData(userInfo); // merge new data into original model.SetData(userInfo); // and all the data back into model for final display if (newUser) { await userInfoDP.AddItemAsync(userInfo); } else { await userInfoDP.UpdateItemAsync(userInfo); } string msg = Module.SaveMessage; if (string.IsNullOrWhiteSpace(msg)) { msg = this.__ResStr("okSaved", "Profile saved"); } if (string.IsNullOrWhiteSpace(Module.PostSaveUrl)) { return(FormProcessed(model, msg)); } else { return(FormProcessed(model, msg, OnClose: OnCloseEnum.GotoNewPage, NextPage: Module.PostSaveUrl)); } } }
public IActionResult Edit(int id) { var model = new EditModel(); model.Item = context.ContentSecuredPaths.Find(id); if (model.Item == null) { return(new NotFoundResult()); } return(EditView(model)); }
public ActionResult Save(EditModel model) { if (ModelState.IsValid) { model.Save(api); var items = Mapper.Map<IEnumerable<Piranha.Models.Alias>, IEnumerable<ListItem>>(api.Aliases.Get()); var current = items.Where(c => c.Id == model.Id).SingleOrDefault(); if (current != null) { current.Saved = true; } return JsonData(true, items); } return JsonData(false); }
public ActionResult Edit(string title) { var model = new EditModel(); var about = !string.IsNullOrEmpty(title) ? Services.About.GetByTitle(title) : Services.About.GetAll().FirstOrDefault(); if (about != null) { model.Title = about.Title; model.Content = about.Content; model.Name = about.Name; } return View(model); }
public ActionResult Edit([Bind(Prefix = "id")] string slug) { var entry = Services.Entry.GetBySlug(slug); var model = new EditModel { Title = entry.Title, Date = entry.DateCreated.ToString("dd MMM yyyy"), Markdown = entry.Markdown, Slug = slug, NewSlug = slug }; return View(model); }
public ActionResult Edit([Bind(Prefix = "id")] string slug) { var entry = Services.Entry.GetBySlug(slug); var model = new EditModel { Title = entry.Title, Date = entry.DateCreated.ToString("dd MMM yyyy", Thread.CurrentThread.CurrentCulture), Markdown = entry.Markdown, Slug = slug, NewSlug = slug, IsPublished = entry.IsPublished ?? true, IsCodePrettified = entry.IsCodePrettified ?? true }; return View(model); }
public ActionResult Edit(EditModel editModel) { try { OpenIDMembershipProvider provider = (OpenIDMembershipProvider)Membership.Provider; OpenIDMembershipUser user = (OpenIDMembershipUser)Membership.GetUser(); user.Update(editModel); provider.UpdateUser(user); return Redirect("/Account/Index"); } catch { return View(); } }
public static EditModel ConvertUserToEditModel(User u) { EditModel m = new EditModel { Firstname = u.Firstname, Lastname = u.Lastname, Email = u.EmailAddress, GeekUserName = u.GeekUserName, FacebookUserName = u.FacebookDetails.email }; return m; }
private MembershipCreateStatus EditUser(EditModel model) { int id = ((Session)HttpContext.Session["Session"]).UserID; User oldUser = db.Users.Single(u => u.UserID == id); if (oldUser.Name != model.UserName) { if (!db.Users.Where(u => u.UserID != id && u.Name == model.UserName).Any()) { oldUser.Name = model.UserName; } else { return MembershipCreateStatus.DuplicateUserName; } } if (oldUser.Email != model.Email) { if (!db.Users.Where(u => u.UserID != id && u.Email == model.Email).Any()) { oldUser.Email = model.Email; } else { return MembershipCreateStatus.DuplicateEmail; } } db.Users.Attach(oldUser); db.ObjectStateManager.ChangeObjectState(oldUser, EntityState.Modified); db.SaveChanges(); return MembershipCreateStatus.Success; }
public ActionResult Edit(EditModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus editStatus = EditUser(model); if (editStatus == MembershipCreateStatus.Success) { return RedirectToAction("Index", "BasicPage"); } else { ModelState.AddModelError("", ErrorCodeToString(editStatus)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Edit(EditModel model) { if (ModelState.IsValid) { //get password string password = userLogic.GetPassword(HttpContext.User.Identity.Name); if (Membership.ValidateUser(HttpContext.User.Identity.Name, password)) { MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name); user.Email = model.Email; Membership.UpdateUser(user); if (userLogic.UpdateUserDetails(HttpContext.User.Identity.Name, model)) { return RedirectToAction("Index", "Home"); } } } //Something wrong return View(model); }
public string get_edit_Name_Level(EditModel model) { _document.Model = model; return _document.Edit(x => x.Name).ToString(); }
public async Task<ActionResult> Edit(EditModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { Id = model.Id, UserName = model.Email, Name = model.Name, LastName = model.LastName }; var result = await this.userService.UpdateAsync(user, model.Roles.Where(r => r.IsSelected).Select(r => r.Name).ToArray()); if (result.Succeeded) { return RedirectToAction("Index", "Home"); } else { this.AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }
public async Task<ActionResult> Edit(string id) { var user = await this.userService.FindByIdAsync(id); if (user != null) { var userRoles = await this.userService.GetRolesAsync(id); var roles = this.userService.GetAllRoleNames(); var model = new EditModel { Id = user.Id, Email = user.UserName, Name = user.Name, LastName = user.LastName, Roles = roles.Select(r => new SelectableItemModel { Name = r, IsSelected = userRoles.Contains(r) }).ToList() }; return View(model); } throw new Exception("Invalid user!"); }
public void EditAccount(EditModel editModel) { this.storage.EditAccount(editModel); var user = this.GetUser(editModel.Id); this.cacheProvider.Invalidate("user-id-" + user.Id, "user-name-" + user.Username, "users"); }
public void EditAccount(EditModel editModel) { var db = this.GetDbContext(); var user = db.Users.Single(u => u.Username == this.GetIdentityName() && u.Deleted == false); user.Name = editModel.Name; user.OpenId = editModel.OpenId ?? string.Empty; user.Email = editModel.Email; user.UserId = editModel.UserId; db.SubmitChanges(); this.SendEmail("admin@iudico", user.Email, "Iudico Notification", "Your details have been changed."); editModel.Id = user.Id; }
public void EditAccount(EditModel editModel) { var identity = HttpContext.Current.User.Identity; var db = GetDbContext(); var user = db.Users.Single(u => u.Username == identity.Name); user.Name = editModel.Name; user.OpenId = editModel.OpenId ?? string.Empty; user.Email = editModel.Email; db.SubmitChanges(); SendEmail("admin@iudico", user.Email, "Iudico Notification", "Your details have been changed."); }
public BatchAddModel(int emptyItemCount) { EditModels = new EditModel[emptyItemCount]; }
public ActionResult Edit() { EditModel editModel = new EditModel((OpenIDMembershipUser)Membership.GetUser()); return View(); }