public IActionResult Edit(int id, IndustryModel industryModel) { if (id != industryModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Industries.Update(industryModel); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IndustryModelExists(industryModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(industryModel)); }
// GET: Industries/Details/5 public async Task <IActionResult> Details(decimal?id) { if (id == null) { return(NotFound()); } var industry = await _context.Industry .Include(a => a.IndustryLink) .FirstOrDefaultAsync(m => m.Id == id); if (industry == null) { return(NotFound()); } //return View(industry); IndustryModel industrymodel = new IndustryModel(); industrymodel.Id = industry.Id; industrymodel.Name = industry.Name; industrymodel.ThumbnailInd = industry.ThumbnailTemp; industrymodel.Description = industry.Description; industrymodel.Keywords = industry.Keywords; industrymodel.Product = new HashSet <Product>(from i in _context.Industry join il in _context.IndustryLink on i.Id equals il.IndustryId join p in _context.Product on il.ProductId equals p.Id where i.Id == id select il.Product).Take(16); return(View(industrymodel)); }
private Task <Industry> IndustryToEntityAsync(IndustryModel model) { return(Task.FromResult(new Industry { Name = model.Name, Id = model.Id })); }
/// <summary> /// Creates a new Industry Entity from a Model /// </summary> /// <param name="industryModel">The target Industry Model</param> /// <returns>Industry</returns> public static Industry MapEntityFromModel(IndustryModel industryModel) { return(new Industry { Name = industryModel.Name, ImgUrl = industryModel.ImgUrl, CreatedOn = industryModel.CreatedOn, }); }
private Industry MapToEntity(IndustryModel model, string requestId = "") { // Perform mapping var entity = Industry.Empty; entity.Id = model.Id ?? String.Empty; entity.Name = model.Name ?? String.Empty; return(entity); }
private IndustryModel MapToModel(Industry entity, string requestId = "") { // Perform mapping var model = new IndustryModel(); model.Id = entity.Id ?? String.Empty; model.Name = entity.Name ?? String.Empty; return(model); }
public async Task <IActionResult> Create(IndustryModel industryModel) { if (ModelState.IsValid) { _context.Add(industryModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(industryModel)); }
/// <summary> /// 取得行业分类的所有列表 /// </summary> /// <returns>行业分类列表</returns> public List <IndustryModel> GetAllList() { List <IndustryModel> lists = new List <IndustryModel>(); using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "SetIndustryBTab_GetAllList", null)) { while (rdr.Read()) { IndustryModel item = new IndustryModel(rdr.GetString(0).Trim(), rdr.GetString(1).Trim(), "", rdr.GetInt32(3)); lists.Add(item); } } return(lists); }
public IndustryModel GetIndustryByName(string IndustryName) { var industryModel = new IndustryModel(); var result = _unitOfWork.industryRepository.Get(data => data.Name == IndustryName).FirstOrDefault(); if (result == null) { var industryId = Convert.ToInt32(ReadConfiguration.MiscellaneousIndustry); result = _unitOfWork.industryRepository.Get(data => data.IndustryId == industryId).FirstOrDefault(); } //var userId = GetLoginUserId(); //var newIndustry = new Industry { Name = IndustryName }; //_unitOfWork.industryRepository.Insert(newIndustry); //_unitOfWork.Save(); //Mapper.Map(newIndustry, industryModel); Mapper.Map(result, industryModel); return(industryModel); }
/// <summary> /// 修改时取表中行业值 /// </summary> /// <param name="IndustryID">返回list</param> /// <returns></returns> public List <IndustryModel> GetIndustryList(string IndustryList) { string[] arrType = IndustryList.Split(','); List <IndustryModel> lists = new List <IndustryModel>(); for (int i = 0; i < arrType.Length; i++) { SqlParameter para = new SqlParameter("@IndustryBID", SqlDbType.Char, 16); para.Value = arrType[i]; using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "SetIndustryBTab_GetListById", para)) { while (rdr.Read()) { IndustryModel item = new IndustryModel(arrType[i], rdr.GetString(1).Trim(), "", rdr.GetInt32(3)); lists.Add(item); } } } return(lists); }
public async Task <StatusCodes> CreateItemAsync(IndustryModel modelObject, string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - Industry_CreateItemAsync called."); Guard.Against.Null(modelObject, nameof(modelObject), requestId); Guard.Against.NullOrEmpty(modelObject.Name, nameof(modelObject.Name), requestId); try { var entityObject = MapToEntity(modelObject, requestId); var result = await _industryRepository.CreateItemAsync(entityObject, requestId); Guard.Against.NotStatus201Created(result, "Industry_CreateItemAsync", requestId); return(result); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - Industry_CreateItemAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - Industry_CreateItemAsync Service Exception: {ex}"); } }
public ActionResult Edit(IndustryModel model, string cdts) { GetConditions(cdts); model.Update(); return(RedirectToAction("AdminIndex", new { Page = model.Page, Cdts = cdts })); }
public ActionResult Create(IndustryModel model, string cdts) { GetConditions(cdts); model.Insert(); return(View("AdminIndex")); }
public async Task <IHttpActionResult> GetExternalLogins(string provider, string error = null) { string redirectUri = string.Empty; var listPositionModel = new List <UserPositionsModel>(); try { if (error != null) { return(BadRequest(Uri.EscapeDataString(error))); } if (!User.Identity.IsAuthenticated) { return(new ChallengeResult(provider, this)); } var redirectUriValidationResult = ValidateClientAndRedirectUri(this.Request, ref redirectUri); if (!string.IsNullOrWhiteSpace(redirectUriValidationResult)) { return(BadRequest(redirectUriValidationResult)); } ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity); if (externalLogin == null) { return(InternalServerError()); } if (externalLogin.LoginProvider != provider) { _authenticationService.SignOut(); return(new ChallengeResult(provider, this)); } var user = await _authenticationService.FindAsync(new UserLoginInfo(externalLogin.LoginProvider, externalLogin.ProviderKey)); bool hasRegistered = user != null; if (!hasRegistered) { var isEmailExist = await _authenticationService.FindByNameAsync(externalLogin.Email); if (isEmailExist != null) { redirectUri = string.Format("{0}#external_access_token={1}&provider={2}&haslocalaccount={3}&external_user_name={4}&error_message={5}", redirectUri, externalLogin.ExternalAccessToken, externalLogin.LoginProvider, hasRegistered.ToString(), externalLogin.Email, "Email has already regestired! Please provide password for login"); return(Redirect(redirectUri)); } } var extraData = GetProfileData(externalLogin.ExternalAccessToken); externalLogin.FirstName = extraData.firstName; externalLogin.LastName = extraData.lastName; string Industry = extraData.industry; var industry = new IndustryModel(); if (Industry != null) { industry = _authenticationService.GetIndustryByName(Industry); } if (user == null) { if (extraData.positions.values != null) { foreach (var data in extraData.positions.values) { var positionModel = new UserPositionsModel(); positionModel.Title = data.title; positionModel.StartMonth = data.startDate != null?data.startDate.month:0; positionModel.StartYear = data.startDate != null?data.startDate.year:0; positionModel.CompanyName = data.company != null ? data.company.name : ""; positionModel.Description = data.summary; positionModel.IsCurrent = data.isCurrent; listPositionModel.Add(positionModel); } } string pictureUrl = extraData.pictureUrl; var imageName = pictureUrl != null?DownlodImageFromLinkedin(pictureUrl, externalLogin.Email) : ""; var userModel = new UserModel() { FirstName = externalLogin.FirstName, LastName = externalLogin.LastName, Email = externalLogin.Email, PictureUrl = ImagePathConstants.ProfileImage_Folder + imageName, //PictureUrl = extraData.pictureUrl, Summary = extraData.summary, LoginProvider = externalLogin.LoginProvider, ProviderKey = externalLogin.ProviderKey, UserPositions = listPositionModel }; if (Industry != null) { userModel.IndustryId = industry.IndustryId; } var response = await _authenticationService.CreateUser(userModel, true); if (response.Success) { hasRegistered = true; } } var claimsIdentity = _authenticationService.ExternalLogin("ExternalCookie", externalLogin.Email, false); var tokenResponse = GenerateLocalAccessTokenResponse(externalLogin.Email, claimsIdentity); var loginModel = new LoginModel(); loginModel.UserName = externalLogin.Email; externalLogin.accessToken = (string)tokenResponse["access_token"]; redirectUri = string.Format("{0}#external_access_token={1}&provider={2}&haslocalaccount={3}&external_user_name={4}&access_token={5}", redirectUri, externalLogin.ExternalAccessToken, externalLogin.LoginProvider, hasRegistered, externalLogin.Email, externalLogin.accessToken); return(Redirect(redirectUri)); } catch (Exception ex) { throw ex; } }