Пример #1
0
        public JsonResult CreateCompany(CreateCompanyVM vm)
        {
            try
            {
                Company newCompany = new Company();
                newCompany.Created    = DateTime.Now;
                newCompany.CreatedBy  = SessionManager.ActiveUser.Id;
                newCompany.Modified   = DateTime.Now;
                newCompany.ModifiedBy = SessionManager.ActiveUser.Id;
                newCompany.IsActive   = true;

                newCompany.Logo        = vm.Logo;
                newCompany.Name        = vm.Name;
                newCompany.City        = vm.City;
                newCompany.District    = vm.District;
                newCompany.Email       = vm.Email;
                newCompany.Phone       = vm.Phone;
                newCompany.State       = vm.State;
                newCompany.Description = vm.Description;

                _cs.Insert(newCompany);

                return(Json(new { Result = true, Message = "Şirket Başarıyla Kaydedildi." }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, ex.Message }));
            }
        }
        public IActionResult Create()
        {
            CreateCompanyVM model = new CreateCompanyVM()
            {
                Company = new CompanyDto()
            };

            return(View(model));
        }
Пример #3
0
        public async Task <IActionResult> Post([FromBody] CreateCompanyVM model)
        {
            if (string.IsNullOrWhiteSpace(model.Name) || model.Name.Length < 3)
            {
                return(BadRequest(model.Name));
            }

            var companyId = _companyService.CreateCompany(model.Name, GetUserId());

            return(CreatedAtAction("Get", new { id = companyId }, companyId));
        }
        public ActionResult Create(CreateCompanyVM model)
        {
            var validator = new CompanyValidator(companyRepository);
            var result    = validator.Validate(model.Company);

            if (result.IsValid)
            {
                var comp = companyRepository.InsertCompany(model.Company);
                companyRepository.SaveChanges();
                return(RedirectToAction("Show", "Company", new { comp.Id }));
            }
            else
            {
                model.Errors = result.Errors.ToDictionary(e => e.PropertyName, e => string.Format(e.ErrorMessage, e.FormattedMessagePlaceholderValues["PropertyName"]));
                return(View(model));
            }
        }
Пример #5
0
        public IActionResult Create(CreateCompanyVM createCompanyVM)
        {
            var config             = new MapperConfiguration(cfg => cfg.CreateMap <CreateCompanyVM, RegisterCompanyDTO>());
            var mapper             = new Mapper(config);
            RegisterCompanyDTO dto = mapper.DefaultContext.Mapper.Map <RegisterCompanyDTO>(createCompanyVM);
            var cid = _userService.CreateCompany(dto);

            if (cid > 0)
            {
                ShowToaster("Welcome", ToasterLevel.Success);
                return(RedirectToAction("CompanyDashboard"));
            }
            else
            {
                ShowToaster("Email-id already exists for this company", ToasterLevel.Danger);
                return(RedirectToAction("RegisterCompany"));
            }
        }
Пример #6
0
        public IActionResult RegisterCompany()
        {
            ViewBag.menu = JsonConvert.SerializeObject(GetCategory());

            CreateCompanyVM createCompanyVM = new CreateCompanyVM();

            createCompanyVM.CountryList = _masterDataService.GetCountries().Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            }).ToList();
            createCompanyVM.BusinessTypeList = _masterDataService.GetBusinessTypes().Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            }).ToList();
            return(View(createCompanyVM));
        }
Пример #7
0
        public async Task <IActionResult> CreateCompany([FromForm] CreateCompanyVM company)
        {
            try
            {
                if (company == null)
                {
                    throw new Exception("company is missing");
                }

                company.LogoFile = HttpContext.Request.Form.Files[0];
                var companyPage =
                    await _companyService.CreateCompanyAsync(company, User.Claims.First(c => c.Type == "UserID").Value);

                return(Ok(companyPage));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #8
0
        public async Task <CompanyPageVM> CreateCompanyAsync(CreateCompanyVM company, string userId)
        {
            var fileId     = (await _fileService.CreateFileDbAsync(company.LogoFile)).Id;
            var newCompany = new Company()
            {
                Name            = company.Name,
                ContactInfo     = company.ContactInfo,
                Vk              = company.Vk,
                Facebook        = company.Facebook,
                Instagram       = company.Instagram,
                Site            = company.Site,
                Describe        = company.Describe,
                SpecificationId = company.SpecificationId,
                FileId          = fileId,
                AdminId         = userId
            };
            var model = await _db.Companys.CreateAsync(newCompany);

            return(new CompanyPageVM(model));
        }