コード例 #1
0
        public EditCompanyDetailViewModel GetCompanyDetail()
        {
            var user = _userService.GetUser();

            var           model         = new EditCompanyDetailViewModel();
            CompanyDetail companyDetail = _companyDetailRepository.Get(x => x.UserId == user.UserId);

            if (companyDetail != null)
            {
                model.ImagePath         = companyDetail.ImageUrl;
                model.UserId            = companyDetail.UserId;
                model.WebSite           = companyDetail.WebSite;
                model.SectorId          = companyDetail.SectorId;
                model.NumberOfEmployees = companyDetail.NumberOfEmployees;
                //model.ImageUrl = companyDetail.ImageUrl;
                model.FoundationYear = companyDetail.FoundationYear;
                model.CompanyName    = companyDetail.CompanyName;
                model.Address        = companyDetail.Address;
                model.About          = companyDetail.About;
                model.NumberOfUnreadSendedMessages = _messageService.GetUnreadSendedMessageCount();
                model.ImageFileName = Path.GetFileName(model.ImagePath);
            }
            model.SectorList = _sectorService.GetSectorList();
            return(model);
        }
コード例 #2
0
        public IActionResult EditCompanyDetail(EditCompanyDetailViewModel model)
        {
            if (ModelState.IsValid && model.ImageUrl != null)
            {
                var errors = ModelState.Where(x => x.Value.Errors.Any()).Select(x => new KeyValuePair <string, string>(x.Key, x.Value.Errors.FirstOrDefault().ErrorMessage)).ToList();

                var uploadedFileExtension  = Path.GetExtension(model.ImageUrl.FileName).ToLower();
                var acceptedFileExtensions = new List <string>()
                {
                    ".png",
                    ".jpg",
                    ".gif",
                    ".bmp",
                    ".jpeg"
                };
                //tanımladığınız dosya türleri arasında değil ise
                if (!acceptedFileExtensions.Contains(uploadedFileExtension))
                {
                    errors.Add(new KeyValuePair <string, string>("ProfileImageFile", "Düzgün dosya gir andaval!"));

                    return(View());
                }

                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "CompanyProfileImages", model.ImageUrl.FileName.Replace(" ", "_") + "");/* + Path.GetFileNameWithoutExtension(model.ProfileImageFile.FileName))*/

                using (var stream = new FileStream(path, FileMode.Create))
                {
                    model.ImageUrl.CopyTo(stream);
                }
                model.ImagePath = path;

                //burayı düzelt resim girmez isen bu ife gelmiyor
                if (_companyDetailService.EditCompanyDetail(model) > 0)
                {
                    //kayıt başarılı tamamlandı, insanları profile geri gönder

                    return(Redirect(Url.Action("Index", "Home")));
                }
                ModelState.AddModelError("SectorId", "Hatalı Sektör Seçimi");
            }
            model.SectorList = _sectorService.GetSectorList();

            return(View(model));
        }
コード例 #3
0
        public SearchJobAdvertisementViewModel GetSearchJobAdvertisementFormData()
        {
            var model = new SearchJobAdvertisementViewModel();

            model.CityId = new List <int?>()
            {
                0
            };
            model.CityList         = _cityService.GetCityListToForm();
            model.EducationLevelId = new List <int?>()
            {
                0
            };
            model.EducationLevelList = _educationLevelService.GetEducationLevelList();
            model.DepartmantId       = new List <int?>()
            {
                0
            };
            model.DepartmantList = _departmantService.GetDepartmantList();
            model.WorkTypeId     = new List <int?>()
            {
                0
            };
            model.WorkTypeList = _workTypeService.GetWorkTypeList();
            model.PositionId   = new List <int?>()
            {
                0
            };
            model.PositionList = _positionService.GetPositionList();
            model.SectorId     = new List <int?>()
            {
                0
            };
            model.SectorList = _sectorService.GetSectorList();

            return(model);
        }