public ActionResult Edit([Bind(Include = "ID,AddBy,AddByName,AddDate,IsAvailable,Name,Introduction,ImgPath,Content,Source,Author,CategoryID")] Info model, string ImgPathToDelete = "") { int successCount = 0, notExistCount = 0; string msg = ""; CommonUtil.RemoveFiles(ImgPathToDelete, out successCount, out notExistCount, out msg); model.UpdateBy = cuser.UserID; model.UpdateByName = cuser.LoginName; model.UpdateDate = DateTime.Now; if (string.IsNullOrEmpty(Request["Introduction"])) { model.Introduction = model.Content.ToNoHtml().ToMaxString(200); } infoService.Update(model); if (infoService.SaveChanges(out msg) > 0) { return(Json(new AjaxResult() { success = true, msg = updateSuccess, url = Url.Action("index", "info", "admin"), moremsg = msg })); } else { return(Json(new AjaxResult() { success = false, msg = updateFailure, moremsg = msg })); } }
public IActionResult Update(string id, InfoModel model) { if (ModelState.IsValid) { var updateCat = _infoService.Update(base.UserId, id, model); } return(Ok()); }
public IActionResult SaveForm(Hi_Core.Domain.Entities.Hi_Core_Info m) { var data = _infoService.FindById(m.Iid); m.Ititle = data.Ititle; m.Type = data.Type; bool res = _infoService.Update(m); if (res) { return(Success("保存成功!")); } else { return(Error("保存失败!")); } }
public async Task <IActionResult> Update(Info model) { if (!_hostingEnvironment.EnvironmentName.Equals("Development")) { return(this.StatusCode(StatusCodes.Status401Unauthorized, $"Você não tem autorização para realizar essa ação!")); } try { var result = await _infoService.Update(model); if (result == null) { return(BadRequest("Erro ao tentar atualizar dados.")); } return(Ok(result)); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status401Unauthorized, $"Você não tem autorização para realizar essa ação!")); } }
public async Task <IActionResult> EditInfo(InfoModel model, IFormFile logoHeader, IFormFile logoFooter) { var entity = _infoService.GetInfo(); if (ModelState.IsValid) { entity.Address = model.Address; entity.Email1 = model.Email1; entity.Email2 = model.Email2; entity.Tel1 = model.Tel1; entity.Tel2 = model.Tel2; entity.FacebookUrl = model.FacebookUrl; entity.InstagramUrl = model.InstagramUrl; entity.TwitterUrl = model.TwitterUrl; entity.YoutubeUrl = model.YoutubeUrl; entity.MapIframe = model.MapIframe.ChangeMapUrl(); entity.SiteTitle = model.SiteTitle; entity.Author = model.Author; entity.Keywords = model.Keywords; entity.Description = model.Description; if (logoHeader != null) { if (logoHeader.Length > 0) { var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg"); var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\info", fileName); using (var stream = new FileStream(path, FileMode.Create)) { await logoHeader.CopyToAsync(stream); entity.LogoHeader = fileName; } } } if (logoFooter != null) { if (logoFooter.Length > 0) { var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg"); var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\info", fileName); using (var stream = new FileStream(path, FileMode.Create)) { await logoFooter.CopyToAsync(stream); entity.LogoFooter = fileName; } } } } _infoService.Update(entity); ToastrService.AddToUserQueue(new Toastr() { Message = Toastr.GetMessage("Firma Bilgileri", EntityStatus.Update), Title = Toastr.GetTitle("Firma Bilgileri", EntityStatus.Update), ToastrType = ToastrType.Info }); return(View(entity.EntityConvert <InfoModel>())); }