public ActionResult SaveJobInfo(Models.JobInfoDTO infoDTO) { AjaxResult result = new AjaxResult(); if (ModelState.IsValid) { TransactionManager.Excute(delegate { IJobInfoService jobService = ContainerManager.Resolve <IJobInfoService>(); UserInfo logUser = UserContext.LoginUser; HxBlogs.Model.UserInfo user = MapperManager.Map <UserInfo>(logUser); JobInfo jobInfo = MapperManager.Map <JobInfo>(infoDTO); jobInfo.Id = user.JobId; user.JobInfo = jobInfo; List <string> fields = new List <string>(); fields.AddRange(new string[] { "Position", "Industry", "WorkUnit", "WorkYear", "Status", "Skills", "GoodAreas" }); jobService.UpdateEntityFields(jobInfo, fields); _userService.UpdateEntityFields(user); UserContext.UpdateUser(user); }); } else { result = GetErrorResult(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 根据查询条件获取设置信息 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <IEnumerable <Setting> > GetSettingsAsync(SettingQuery query) { try { string sql = "SELECT * FROM Setting WHERE 1=1"; if (query.Id != null) { sql += " AND id = @Id"; } if (!string.IsNullOrWhiteSpace(query.SystemCode)) { sql += " AND systemCode = @SystemCode"; } if (query.TypeCode != null) { sql += " AND typeCode = @TypeCode"; } var info = MapperManager.SetMapper <Setting, SettingQuery>(query); return(await _mysqlRespository.QueryListAsync(sql, info)); } catch (Exception ex) { _log.Error("GetSettingsAsync method error:" + ex); throw; } }
public ActionResult Create(AreaCreateViewModel model) { if (ModelState.IsValid) { var input = MapperManager.Map <AreaDto>(model); try { var result = _areaManageService.CreateArea(input); if (result.Id > 0) { return(RedirectToAction( "Item", "Layout", new { id = model.LayoutId })); } } catch (NotUniqueException) { ModelState.AddModelError("NotUnique", LanguageSummary.DescriptionNotUnique); } } return(View(model)); }
public ActionResult Create(EventCreateViewModel model) { if (ModelState.IsValid) { EventDto result = null; var eventInput = MapperManager.Map <EventInputDto>(model); try { result = _eventManageService.CreateEvent(eventInput); } catch (HasNoSeatsException) { ModelState.AddModelError("EventNoSeats", LanguageSummary.EventNoSeats); } catch (NotUniqueException) { ModelState.AddModelError("NotUnique", LanguageSummary.DescriptionOrNameNotUnique); } catch (DateInPastException) { ModelState.AddModelError("NotUnique", LanguageSummary.DateInPast); } if (result != null && result.Id > 0) { return(RedirectToAction("Index", "Event")); } } return(View(model)); }
public ActionResult SaveBasicInfo(Models.BasicInfoDTO infoDTO) { AjaxResult result = new AjaxResult(); if (ModelState.IsValid) { TransactionManager.Excute(delegate { IBasicInfoService basicService = ContainerManager.Resolve <IBasicInfoService>(); UserInfo logUser = UserContext.LoginUser; HxBlogs.Model.UserInfo user = MapperManager.Map <UserInfo>(logUser); BasicInfo basicInfo = MapperManager.Map <BasicInfo>(infoDTO); basicInfo.Id = user.BasicId; user.BasicInfo = basicInfo; user.NickName = infoDTO.NickName; List <string> fields = new List <string>(); fields.AddRange(new string[] { "RealName", "QQ", "WeChat", "Mobile", "Birthday", "Address", "Description" }); if (string.IsNullOrEmpty(logUser.BasicInfo.Gender)) { fields.Add("Gender"); } _userService.UpdateEntityFields(user, "NickName"); basicService.UpdateEntityFields(basicInfo, fields); UserContext.UpdateUser(user); }); } else { result = GetErrorResult(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(int layoutId) { var newEventInput = _eventManageService.ConfigureEventBeforeCreation(layoutId); var newEventViewModel = MapperManager.Map <EventCreateViewModel>(newEventInput); return(View(newEventViewModel)); }
public ActionResult Edit(int id) { var output = _venueManagementService.GetVenue(id); var model = MapperManager.Map <VenueEditViewModel>(output); return(View(model)); }
public ActionResult Edit(int id) { var eventInput = _eventManageService.ConfigureEventBeforeEdit(id); var eventEditViewModel = MapperManager.Map <EventEditViewModel>(eventInput); return(View(eventEditViewModel)); }
public ActionResult Slider() { // chane to slider images List <SliderVM> sliders = MapperManager.GetMapperInstance().Map <List <SliderVM> >(marvelManagerBll.GetSliders()); return(PartialView(sliders)); }
/// <summary> /// Metodo que consulta un objeto por id /// </summary> /// <param name="oid">identificador del objeto "Llave primaria"</param> /// <returns></returns> public BusinessObject GetObjectByOid(object oid) { try { using (UnitOfWork unit = SessionManager <Persistent> .GetNewUnitOfWork()) { BusinessObject outObjectBO = Activator.CreateInstance <BusinessObject>(); Persistent persistenObject = unit.GetObjectByKey <Persistent>(oid); if (persistenObject != null) { MapperManager <Persistent, BusinessObject> mapper = TransformerFactory.Create <Persistent, BusinessObject>(); outObjectBO = mapper.MapperPersistent2BO(persistenObject); return(outObjectBO); } else { return(default(BusinessObject)); } } } catch (Exception) { throw; } }
/// <summary> /// Metodo que permite consultar un procedimiento almacenado /// </summary> /// <param name="ProcedureName">nombre del procedimiento almacenado</param> /// <param name="list">lista de parametros</param> /// <returns></returns> public List <BusinessObject> GetProcedure(string procedureName, params object[] list) { try { List <BusinessObject> outList = Activator.CreateInstance <List <BusinessObject> >(); using (UnitOfWork unit = SessionManager <Persistent> .GetNewUnitOfWork()) { OperandValue[] parametros = GetOperands(list); ICollection <Persistent> response = new List <Persistent>(); response = unit.GetObjectsFromSproc <Persistent>(procedureName, parametros); #if DEBUG var tipoRecibido = typeof(Persistent).GetType().Name; var totalElementos = response.Count; var totalParametrosProcedimiento = list.Count(); #endif MapperManager <Persistent, BusinessObject> mapper = TransformerFactory.Create <Persistent, BusinessObject>(); foreach (var item in response.ToList <Persistent>()) { outList.Add(mapper.MapperPersistent2BO(item)); } } return(outList); } catch (Exception) { throw; } }
public ActionResult Login(User model, string returnUrl) { MapperManager.GetInstance(); var validUser = securityManager.Login(model); if (validUser != null) { if (!validUser.Activo) { ModelState.AddModelError("", "El usuario no se encuentra activo."); return(View(model)); } Response.Cookies.Add(securityManager.GetAuthCookie(validUser)); var ciudad = ciudadesManager.GetCiudad(validUser.CiudadId); Session["ciudadId"] = validUser.CiudadId; Session["ciudadNombre"] = ciudad.Nombre; return(RedirectToAction("Index", "Home")); } // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos."); return(View(model)); }
public ActionResult Edit(int id) { var output = _layoutManageService.GetLayout(id); var model = MapperManager.Map <LayoutEditViewModel>(output); return(View(model)); }
/// <summary> /// Disposes default writer safely /// </summary> public static void Dispose() { if (JKLogger.writer != null) { MapperManager.DisposeDefaultMappers(); JKLogger.writer = null; } }
public ActionResult Edit(int id) { var output = _areaManageService.GetArea(id); var model = MapperManager.Map <AreaEditViewModel>(output); return(View(model)); }
public ActionResult Profiles() { Models.BasicInfoDTO basicInfo = MapperManager.Map <Models.BasicInfoDTO>(UserContext.LoginUser.BasicInfo); basicInfo.NickName = UserContext.LoginUser.NickName; Models.JobInfoDTO jobInfo = MapperManager.Map <Models.JobInfoDTO>(UserContext.LoginUser.JobInfo); ViewBag.JobInfo = jobInfo; ViewBag.AvatarUrl = UserContext.LoginUser.AvatarUrl; return(View(basicInfo)); }
private ActionResult Edit(string hexId, bool isMd) { EditViewModel vm = new EditViewModel() { MarkDown = isMd?"Y":"N" }; if (string.IsNullOrEmpty(hexId)) { if (isMd) { vm.Content = FileHelper.GetString(Server.MapPath("~/Plugins/editormd/template.md")); } } else { long blogId = Convert.ToInt64(Helper.FromHex(hexId)); Blog blog = this._blogService.GetEntityByID(blogId); if (blog == null) { throw new NotFoundException("找不到当前文章!"); } vm = MapperManager.Map <EditViewModel>(blog); vm.PersonTags = blog.BlogTags; vm.HexId = hexId; if (!string.IsNullOrEmpty(blog.BlogTags)) { Dictionary <long, string> tagDic = new Dictionary <long, string>(); string[] tagArr = blog.BlogTags.Split(','); foreach (string tagId in tagArr) { BlogTag blogTag = _tagService.GetEntityByID(Convert.ToInt32(tagId)); if (blogTag != null) { tagDic.Add(blogTag.Id, blogTag.Name); } } ViewBag.PersonTags = tagDic; } } if (string.IsNullOrEmpty(vm.PersonTags)) { vm.PersonTags = ""; } IBlogTypeService typeService = ContainerManager.Resolve <IBlogTypeService>(); ICategoryService cateService = ContainerManager.Resolve <ICategoryService>(); IEnumerable <Category> categories = cateService.GetEntities(c => true). OrderByDescending(c => c.Order); IEnumerable <BlogType> types = typeService.GetEntities(t => true). OrderByDescending(t => t.Order); IEnumerable <BlogTag> tags = _tagService.GetEntities(t => t.UserId == UserContext.LoginUser.Id); ViewBag.Categories = categories; ViewBag.Types = types; ViewBag.Tags = tags; return(View(vm)); }
/// <summary> /// 上传头像 /// </summary> /// <returns></returns> public ActionResult UploadAvatar() { AjaxResult result = new AjaxResult(); HttpFileCollectionBase imgFiles = Request.Files; if (imgFiles.Count <= 0) { result.Success = false; result.Message = "请上传文件!"; return(Json(result, JsonRequestBehavior.AllowGet)); } HttpPostedFileBase file = imgFiles["file"]; long fileLength = file.InputStream.Length; if (fileLength > 2 * 1024 * 1024) { result.Message = "文件超出限制. 最大为: 2MB."; result.Success = false; return(Json(result, JsonRequestBehavior.AllowGet)); } UserInfo logUser = UserContext.LoginUser; UserInfo userInfo = MapperManager.Map <UserInfo>(logUser); //路径处理 string rootPath = WebHelper.GetAppSettingValue(ConstInfo.UploadPath); string dirPath = rootPath + "/avatar/" + userInfo.UserName + "/" + DateTime.Now.ToString("yyyyMM") + "/"; //绝对路径 string mapPath = Server.MapPath(dirPath); FileHelper.TryCreateDirectory(mapPath); //文件名 string sourceFileName = file.FileName; string sourceName = Path.GetFileNameWithoutExtension(sourceFileName); HttpPostedFileBase _160x160File = imgFiles["file1"]; string _160x160FileName = _160x160File.FileName; string _160x160Path = Path.Combine(mapPath, _160x160FileName); _160x160File.SaveAs(_160x160Path); string _32FileName = sourceName + "-32x32" + Path.GetExtension(_160x160FileName); userInfo.AvatarUrl = Path.Combine(dirPath, _32FileName); //异步保存 Task.Run(() => { //32x32 string _32Path = Path.Combine(mapPath, _32FileName); ImageManager.MakeThumbnail(_160x160Path, _32Path, 32, 32, ThumbnailMode.Cut); string filePath = Path.Combine(mapPath, sourceFileName); file.SaveAs(filePath); IUserInfoService _userService = ContainerManager.Resolve <IUserInfoService>(); _userService.UpdateEntityFields(userInfo, "AvatarUrl"); }); UserContext.UpdateUser(userInfo); result.Resultdata = WebHelper.GetFullUrl(Path.Combine(dirPath, _160x160FileName)); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult RelatedItemListing(int id, int itemId) { List <ItemVM> items = MapperManager.GetMapperInstance().Map <List <ItemVM> >(marvelManagerBll.GetItemsByCategory(id)); ItemVM item = items.FirstOrDefault(x => x.Id == itemId); if (item != null) { items.Remove(item); } return(PartialView(items)); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (this.mapper != null) { MapperManager.DisposeMapper(this.mapper); this.mapper = null; } } }
public ActionResult Index() { var venues = _venueManagementService.ListVenues(); var venuesListViewModel = new VenuesListViewModel { Venues = MapperManager.Map <List <VenueViewModel> >(venues), }; return(View(venuesListViewModel)); }
public static void RegisterMappings() { MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg => { cfg.CreateMap <SliderDTO, SliderVM>().ForMember(x => x.Image, opt => opt.Ignore()).ReverseMap(); cfg.CreateMap <CategoryDTO, CategoryVM>().ForMember(x => x.Image, opt => opt.Ignore()).ReverseMap(); cfg.CreateMap <ItemDTO, ItemVM>().ForMember(x => x.Image, opt => opt.Ignore()).ReverseMap(); }); MapperManager.RegisterMappings(mapperConfiguration); }
public static void RegisterWindowsEvent() { // haetaan default mapperin instanssi mapper managerilta var events = MapperManager.GetDefaultMapper(typeof(WindowsEvent)) as WindowsEvent; // rekisteröidään app.configin mukaisilla arvoilla if (events != null) { events.RegisterSource(); } }
public ActionResult Item(int id) { var venueItem = _venueManagementService.GetVenueLayouts(id); var venueItemViewModel = MapperManager.Map <VenueItemViewModel>(venueItem); venueItemViewModel.LayoutsList = new LayoutsListViewModel { Layouts = MapperManager.Map <List <LayoutViewModel> >(venueItem.Layouts) }; return(View(venueItemViewModel)); }
public ActionResult Index() { var purchaseHistory = _purchaseFlowService.ListPurchaseHistory(UserId); var purchaseHistoryViewModel = MapperManager.Map <List <PurchaseHistoryItemViewModel> >(purchaseHistory); var model = new PurchaseHistoryViewModel { History = purchaseHistoryViewModel, }; return(View(model)); }
private CartViewModel GetTickets() { TicketDto[] tickets; tickets = _cartManageService.GeTickets(GetCart()); var cartModel = new CartViewModel { Tickets = MapperManager.Map <List <TicketViewModel> >(tickets), }; return(cartModel); }
public ActionResult Index(LoginVM model, string returnUrl) { if (!ModelState.IsValid) { List <ModelErrorCollection> errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); foreach (ModelErrorCollection error in errors) { TempData["Error"] += error[0].ErrorMessage + "<br/>"; } return(View("Index", model)); } // fecth active product from the products table var user = adminManagerBll.AuthenticateUser(model.UserName, model.Password); if (user == null) { model.Password = string.Empty; TempData["Error"] = "Invalid credentials. Please try again."; return(View("Index", model)); } var userVM = MapperManager.GetMapperInstance().Map <UserDTO>(user); if (userVM != null) { model.Password = string.Empty; FormsAuthentication.SetAuthCookie(model.UserName, false); model.Roles = Constants.ROLE_ADMIN; var authTicket = new FormsAuthenticationTicket(1, userVM.UserName, DateTime.Now, DateTime.Now.AddMinutes(40), false, model.Roles); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { model.Password = string.Empty; TempData["Error"] = "Invalid credentials. Please try again."; return(View("Index", model)); } }
public ActionResult Details(int itemId) { ItemVM item = MapperManager.GetMapperInstance().Map <ItemVM>(marvelManagerBll.GetItemById(itemId)); if (item != null) { var categoryDto = marvelManagerBll.GetCategoryById(item.CategoryId); if (categoryDto != null) { ViewBag.categoryName = categoryDto.Name; } } return(View(item)); }
public ActionResult GetAllItems() { List <ItemVM> items = new List <ItemVM>(); foreach (var cat in Categories) { List <ItemVM> itemForCat = MapperManager.GetMapperInstance().Map <List <ItemVM> >(marvelManagerBll.GetItemsByCategory(cat.Id)); if (itemForCat.Count > 0) { items.AddRange(itemForCat); } } return(PartialView(items)); }
public ActionResult Item(int id) { var layout = _layoutManageService.GetLayoutAreas(id); var layoutItemViewModel = MapperManager.Map <LayoutItemViewModel>(layout); layoutItemViewModel.Venue = MapperManager.Map <VenueViewModel>(layout.Venue); layoutItemViewModel.AreasList = new AreasListViewModel { Areas = MapperManager.Map <List <AreaViewModel> >(layout.Areas) }; return(View(layoutItemViewModel)); }