public void Resume(int id) { var item = this.PointGiftService.GetById(id); if (item != null && item.State == PointGiftStates.Invalid) { item.State = PointGiftStates.Normal; PointGiftService.Update(item); Logger.LogWithSerialNo(LogTypes.PointGiftResume, SerialNoHelper.Create(), id, item.DisplayName); AddMessage("resume.success", item.DisplayName); } }
public void Save() { var serialNo = SerialNoHelper.Create(); var item = PointGiftService.GetById(PointGiftId); if (item != null) { TransactionHelper.BeginTransaction(); item.DisplayName = DisplayName; item.Point = Point; HttpContext contxt = HttpContext.Current; string oldFileName = ""; if (Photo != null && Photo.File != null) { var name = Guid.NewGuid().ToString("N") + ".jpg"; oldFileName = item.Photo; item.Photo = name; var fileName = contxt.Server.MapPath("~/content/pointgiftphotos/" + name); Moonlit.IO.DirectoryEnsure.EnsureFromFile(fileName); Photo.File.SaveAs(fileName); } item.Description = Description; item.Category = Category; OnSave(item); PointGiftService.Update(item); AddMessage("success", DisplayName); Logger.LogWithSerialNo(LogTypes.PointGiftEdit, serialNo, item.PointGiftId, DisplayName); if (!string.IsNullOrWhiteSpace(oldFileName)) { try { File.Delete(contxt.Server.MapPath("~/content/pointgiftphotos/" + oldFileName)); } catch (Exception ex) { Logger.Error(LogTypes.PointGiftEdit, ex); } } TransactionHelper.Commit(); } }