Example #1
0
        public void Save(AddCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (NoErrors(model))
                {
                    #region Saving data to database

                    var company = new Company
                    {
                        ID         = model.ID,
                        Name       = model.Name,
                        ActivityID = ++model.ActivityID //SQL index starts from 1, asp dropdownlist index starts from 0
                    };

                    int companyId;

                    CompanyRepository.SaveCompany(company);
                    companyId = CompanyRepository.GetLastInsertedIdentity();

                    foreach (var town in this.ViewStateTowns)
                    {
                        ContactsRepository.AddCompanyTownLink(companyId, town.ID);
                    }

                    #endregion

                    this.ClearErrors();
                    this.ClearViewState();
                    this.JavaScriptAlert("Компания сохранена успешно");
                }
            }
        }
Example #2
0
        public static AddCompanyViewModel RegCompanySuccess()
        {
            UserInfoViewModel userInfo = new UserInfoViewModel
            {
                FirstName  = "Ислам",
                SecondName = "Байгазиев",
                MiddleName = "Test",
                BirthDay   = "13.09.1998",
                Email      = "*****@*****.**",
                Inn        = "12345678912345",
            };

            ContactInfoViewModel contactInfo = new ContactInfoViewModel
            {
                MobilePhone = "0555800565"
            };


            AddCompanyViewModel model = new AddCompanyViewModel
            {
                NameCompany = "Samsung",
                InnCompany  = "12345678912345",
                OkpoCompany = "Test",
                DateOfInitialRegistration         = "13.09.1998",
                DateOfRegistrationMinistryJustice = "13.09.2017",
                RegistrationNumberSocialFund      = "654116513",
                NumberOfEmployees     = 1,
                ContactInfo           = contactInfo,
                RegistrationAuthority = "CKK",
                IssuedBy = "Stalin"
            };

            return(model);
        }
        public ActionResult AddNewCompany(AddCompanyViewModel newCompany)
        {
            if (ModelState.IsValid)
            {
                Company company = _mapper.Map <Company>(newCompany);
                company.CompanyIdentificator = _keyGenerator.GenerateNewId();

                _context.companyRepository.AddCompany(company);

                #region EntityLogs

                var logInfoAddCompany = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addCompany"]);
                _logger.AddCompanyLog(company, logInfoAddCompany);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddCompany = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addCompany"], "Nazwa przedsiębiorstwa: " + company.CompanyName);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddCompany);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnCompany", new { companyIdentificator = company.CompanyIdentificator, TypeOfAction = "Add" }));
            }

            return(View(newCompany));
        }
Example #4
0
        private async Task <User> CreateUserAsync(AddCompanyViewModel model)
        {
            var user = new User
            {
                Address     = model.Address,
                Document    = model.Document,
                Email       = model.Username,
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                PhoneNumber = model.PhoneNumber,
                UserName    = model.Username
            };

            var result = await _userHelper.AddUserAsync(user, model.Password);

            if (result != IdentityResult.Success)
            {
                return(null);
            }
            var newUser = await _userHelper.GetUserByEmailAsync(model.Username);

            await _userHelper.AddUserToRoleAsync(newUser, "Technical");

            return(newUser);
        }
        public void ДопустимОткрытаCтраницаРегистрацииСотрудника()
        {
            OpenPage("http://*****:*****@");
            Click("id", "logInButton");
            Click("id", "LeftNav");
            SummaryDisplayed("AddCompany");
            Click("id", "AddCompany");
            AddCompanyViewModel model = ModelData.RegCompanySuccess();

            TextToElement("CompanyName", model.NameCompany);
            Click("id", "LegalForm");
            Click("xpath", "//option[text()='ОАО']");
            Click("id", "PropertyType");
            Click("xpath", "//option[text()='Частная']");
            TextToElement("Inn", model.InnCompany);
            TextToElement("Okpo", model.OkpoCompany);
            TextToElement("SocialFundNumber", model.RegistrationNumberSocialFund);
            TextToElement("RegAuthority", model.RegistrationAuthority);
            TextToElement("DORministryJustice", model.DateOfRegistrationMinistryJustice);
            TextToElement("IssuedBy", model.IssuedBy);
            TextToElement("DateofInitialReg", model.DateOfInitialRegistration);
            Click("id", "TaxInspection");
            Click("xpath", "//option[text()='Ленинский']");
            Click("id", "Residency");
            Click("xpath", "//option[text()='Резидент']");
            TextToElement("MobilePhone", model.ContactInfo.MobilePhone);

            Click("id", "SendClick");
        }
Example #6
0
 public ActionResult AddCompany(AddCompanyViewModel model)
 {
     if (model.CompanyName != null)
     {
         if (ValidateEmail(model.Email))
         {
             var c = new Company()
             {
                 Name = model.CompanyName, Email = model.Email, Mobile = model.Mobile, ActivityStatus = true
             };
             _service.AddCompany(c);
             return(RedirectToAction("Companies"));
         }
         else
         {
             ModelState.AddModelError("", "Email is incorrect");
             return(View());
         }
     }
     else
     {
         ModelState.AddModelError("", "Name is required field");
         return(View());
     }
 }
        public Company CreateCompany(AddCompanyViewModel model, RegistrationData registrData, ContactInfo contactInfo)
        {
            string logoPath = String.Empty;

            if (model.Logo != null)
            {
                var path = Path.Combine(
                    environment.WebRootPath,
                    $"images\\{model.NameCompany}\\Logo");
                fileUploadService.Upload(path, model.Logo.FileName, model.Logo);
                logoPath = $"images/{model.NameCompany}/Logo/{model.Logo.FileName}";
            }


            Company company = new Company
            {
                NameCompany    = model.NameCompany,
                LegalFormId    = model.LegalFormId,
                PropertyTypeId = model.PropertyTypeId,
                INN            = model.InnCompany,
                CodeOKPO       = model.OkpoCompany,
                RegistrationNumberSocialFund = model.RegistrationNumberSocialFund,
                ResidencyId        = model.ResidencyId,
                CountryId          = model.CountryId,
                NumberOfEmployees  = model.NumberOfEmployees,
                RegistrationDataId = registrData.Id,
                ContactInfoId      = contactInfo.Id,
                Logo = logoPath
            };

            context.Companies.Add(company);
            context.SaveChanges();
            return(company);
        }
Example #8
0
        public async Task <IActionResult> AddCompany()
        {
            var model = new AddCompanyViewModel();
            await _companyService.ChangeViewModel(model);

            return(View(model));
        }
Example #9
0
 public AddCompanyView(CompanyListViewModel companyListViewModel, CompanyService companyService) : this()
 {
     _companyListViewModel = companyListViewModel;
     _companyService       = companyService;
     _companyToAdd         = new AddCompanyViewModel(_companyService);
     DataContext           = _companyToAdd;
 }
Example #10
0
        public ActionResult AddNewCompany(AddCompanyViewModel newCompany)
        {
            if (ModelState.IsValid)
            {
                Company company = new Company
                {
                    CompanyIdentificator = ObjectId.GenerateNewId().ToString(),

                    CompanyName       = newCompany.CompanyName,
                    Email             = newCompany.Email,
                    Phone             = newCompany.Phone,
                    Country           = newCompany.Country,
                    City              = newCompany.City,
                    PostCode          = newCompany.PostCode,
                    Address           = newCompany.PostCode,
                    NumberOfApartment = newCompany.NumberOfApartment
                };

                _context.AddCompany(company);

                return(RedirectToAction("AddNewCompanyConfirmation", new { companyIdentificator = company.CompanyIdentificator }));
            }

            return(View(newCompany));
        }
Example #11
0
        public async Task <IActionResult> Post([FromBody] AddCompanyViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            if (await _companyRepo.IsExistNameAsync(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Global.Common.ThisNameExist);
                return(BadRequest(ModelState.GetWithErrorsKey()));
            }

            var company = new Company(model.Name);

            var affectedRows = await _companyRepo.AddAsync(company);

            if (affectedRows > 0)
            {
                var viewModel = AutoMapper.Mapper.Map <CompanyViewModel>(company);

                return(CreatedAtRoute("GetCompany", new { id = company.Number }, viewModel));
            }
            return(BadRequest());
        }
Example #12
0
        public virtual ActionResult AddCompany(AddCompanyViewModel model)
        {
            if (model.ExistingCompanyId == 0 && !model.CreateNewCompany)
            {
                ModelState.AddModelError("", "You must either mark to create a new company, or select a company to sync with");
            }

            if (!ModelState.IsValid)
            {
                var jobSearch = _context.Users.Where(x => x.Id == CurrentUserId).Select(x => x.LastVisitedJobSearch).Single();
                model.CreateCompanyList(jobSearch);
                return(View(model));
            }

            if (model.CreateNewCompany)
            {
                var result = _addCompanyProcess.Execute(new AddJigsawCompanyParams {
                    JigsawId = model.JigsawId, RequestingUserId = CurrentUserId
                });
                return(RedirectToAction(MVC.CompanySearch.Jigsaw.AddCompanySuccess(result.CompanyId, result.CompanyName)));
            }

            // else
            return(RedirectToAction(MVC.CompanySearch.Jigsaw.Sync(model.ExistingCompanyId, model.JigsawId)));
        }
Example #13
0
        public AddCompany()
        {
            AddCompanyViewModel _ACVM;

            InitializeComponent();
            _ACVM            = new AddCompanyViewModel();
            this.DataContext = _ACVM;
        }
 public AddCompanyViewModel GetCompaniesSelectList(AddCompanyViewModel company)
 {
     company.Countries      = GetCountries();
     company.LegalForms     = GetLegalForms();
     company.PropertyTypes  = GetPropertyTypes();
     company.Residencies    = GetResidencies();
     company.TaxInspections = GetTaxInspections();
     return(company);
 }
Example #15
0
        public async Task <IActionResult> AddCompany(AddCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _companyService.AddCompanyAsync(model);
            }

            return(View());
        }
Example #16
0
        // GET: Companies/Create
        public async Task <IActionResult> Create()
        {
            var model = new AddCompanyViewModel
            {
                CompanyTypes = _combosHelper.GetComboCompanyTypes()
            };

            model.CompanyTypes = _combosHelper.GetComboCompanyTypes();
            return(View(model));
        }
Example #17
0
        public virtual ActionResult AddCompany(int jigsawId, string companyName)
        {
            var jobSearch = _context.Users.Where(x => x.Id == CurrentUserId).Select(x => x.LastVisitedJobSearch).Single();
            var model     = new AddCompanyViewModel {
                JigsawId = jigsawId, JigsawCompanyName = companyName
            };

            model.CreateCompanyList(jobSearch);
            return(View(model));
        }
Example #18
0
        public async Task <ActionResult <CompanyViewModel> > AddCompany([FromBody] AddCompanyViewModel companyInput)
        {
            var result = await _companyRepository.Create(new Company(companyInput));

            if (result == null)
            {
                return(BadRequest());
            }

            return(Ok(new CompanyViewModel(result)));
        }
Example #19
0
 private void AddCompany()
 {
     var vm = new AddCompanyViewModel();
     if (dialogSvc.ShowDialog(vm))
     {
     ICompany company = vm.Item.Company;
     if (company != null)
     {
         addressBook.AddCompany(company);
     }
     }
 }
Example #20
0
        public async Task ChangeViewModel(AddCompanyViewModel model)
        {
            var offices = await _officeRepo.GetPostOfficesAsync();

            model.Offices = new SelectList(offices, "OfficeId", "Name");
            var regions = await _regionRepo.GetRegionsAsync();

            if (model.OfficeId.HasValue)
            {
                var regionsByOfficeId = regions.Where(x => x.PostOfficeId == model.OfficeId.Value);
                model.Regions = new SelectList(regionsByOfficeId, "RegionId", "RegionName");
            }
        }
Example #21
0
        public void AddCompany(AddCompanyViewModel model)
        {
            try
            {
                if (model != null)
                {
                    MasterCompany entity = new MasterCompany();
                    entity.CompanyName     = model.CompanyName;
                    entity.CompanyAddress  = model.CompanyAddress;
                    entity.CompanyLogo     = model.CmpLogo;
                    entity.CountryRowID    = model.CountryRowID;
                    entity.StateRowID      = model.StateRowID;
                    entity.DistrictRowID   = model.DistrictRowID;
                    entity.LocationRowID   = model.LocationRowID;
                    entity.GeneralEmail    = model.GeneralEmail;
                    entity.MobileNo        = model.MobileNo;
                    entity.PhoneNo         = model.PhoneNo;
                    entity.FaxNo           = model.FaxNo;
                    entity.BillingEmail    = model.BillingEmail;
                    entity.BillingDName    = model.BillingDName;
                    entity.InitiationEmail = model.InitiationEmail;
                    entity.InitiationDName = model.InitiationDisplay;
                    entity.InsuffDName     = model.InsuffDName;
                    entity.InsuffEmail     = model.InsuffEmail;
                    entity.ReportEmail     = model.ReportEmail;
                    entity.ReportDName     = model.ReportDName;
                    entity.MISDName        = model.MISDName;
                    entity.MISEmail        = model.MISEmail;
                    entity.OtherDName      = model.OtherDName;
                    entity.OtherEmail      = model.OtherEmail;
                    entity.BillingEmail    = model.BillingEmail;
                    entity.SMTPServer      = model.SMTPServer;
                    entity.SMTPPort        = model.Port;
                    entity.SMTPUserName    = model.SMTPUserName;
                    entity.SMTPPassword    = model.SMTPPassword;
                    entity.EnableSsl       = Convert.ToByte(model.EnableSsl);
                    entity.Status          = model.Status;

                    db.MasterCompanies.Add(entity);
                }
                else
                {
                    throw new Exception("Company could not be blank!");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #22
0
 public Company(AddCompanyViewModel src) : base()
 {
     Name         = src.Name;
     Address      = src.Address;
     OfficePhone  = src.OfficePhone;
     OfficeEmail  = src.OfficeEmail;
     PostalCode   = src.PostalCode;
     City         = src.City;
     Province     = src.Province;
     Country      = src.Country;
     Contact      = src.Contact;
     ContactPhone = src.ContactPhone;
     ContactEmail = src.ContactEmail;
 }
        public async Task <IActionResult> AddCompany(AddCompanyViewModel companyModel)
        {
            if (companyModel == null)
            {
                return(BadRequest("Object of type company is null"));
            }
            if (ModelState.IsValid)
            {
                var company = AddCompanyToCompanyDTOMapper.Instance.Map(companyModel);
                await companyService.AddCompany(company);

                return(RedirectToAction(nameof(GetAllCompanies)));
            }
            return(View());
        }
        public RegistrationData CreateRegistrationDate(AddCompanyViewModel model)
        {
            RegistrationData registrData = new RegistrationData
            {
                RegistrationAuthority             = model.RegistrationAuthority,
                DateOfRegistrationMinistryJustice = DateTime.Parse(model.DateOfRegistrationMinistryJustice),
                IssuedBy = model.IssuedBy,
                DateOfInitialRegistration = DateTime.Parse(model.DateOfInitialRegistration),
                TaxInspectionId           = model.TaxInspectionId
            };

            context.RegistrationDatas.Add(registrData);
            context.SaveChanges();
            return(registrData);
        }
Example #25
0
        public async Task <IActionResult> Add(AddCompanyViewModel company)
        {
            //TODO: make company add friendly error page
            if (!ModelState.IsValid)
            {
                this.TempData.AddFailureMessage(string.Format(FailureAddItemMessage, company.Name));
                return(this.RedirectToAction(nameof(Index)));
                //return this.BadRequest();
            }

            await companiesServices.AddCompanyAsync(company.Name);

            this.TempData.AddSuccessMessage(string.Format(SuccessAddItemMessage, company.Name));
            return(this.RedirectToAction(nameof(Index)));
        }
        public IActionResult AddCompany()
        {
            AddCompanyViewModel company = new AddCompanyViewModel
            {
                FactAddress = new FactAddressViewModel {
                    Countries = selectListService.GetCountries()
                },
                LegalAddress = new LegalAddressViewModel {
                    Countries = selectListService.GetCountries()
                },
                ContactInfo = new ContactInfoViewModel()
            };

            company = selectListService.GetCompaniesSelectList(company);
            return(View(company));
        }
Example #27
0
        public IActionResult Add(AddCompanyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                // if model state is not valid, redirect user to AddCompany page and list validation errors
                return(BadRequest(ModelState));
            }

            var addCompanyDto = mapper.Map <AddCompanyDTO>(model);
            var message       = new AddCompanyMessage {
                Company = addCompanyDto
            };

            var responseMessage = bus.Request <AddCompanyMessage, AddCompanyResponseMessage>(message);

            return(RedirectToAction("Details", "Companies", new { id = responseMessage.Company.Id }));
        }
Example #28
0
        public async Task AddCompanyAsync(AddCompanyViewModel model)
        {
            var company = await _companyRepo.GetCompanyByNameAsync(model.Name);

            if (company != null)
            {
                throw new Exception("Firma już istnieje w bazie!");
            }

            var office = await _officeRepo.GetPostOfficeByName(model.Name);

            var regions = await _regionRepo.GetRegionsAsync();

            var region = regions.SingleOrDefault(x => x.PostOfficeId == office.OfficeId);

            company = new Company(region.RegionId, Guid.NewGuid(), model.Name, model.Adress, model.Longitude, model.Latitude, model.StartHour, model.FinishHour);

            await _companyRepo.AddCompanyAsync(company);
        }
Example #29
0
        public bool NoErrors(AddCompanyViewModel model)
        {
            var errors = new Dictionary <int, string>();

            if (this.ViewStateTowns.Count == 0)
            {
                errors.Add(0, "Выберите город(а), где находится эта компания.<br/>");
            }

            if (errors.Count > 0)
            {
                //To restore CompanyName in input field after postback
                this.ViewStateCompanyName = model.Name;
                this.ShowErrorMessage(errors);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #30
0
        public IActionResult Post([FromBody] AddCompanyViewModel companyToAdd)
        {
            if (!IsMerchant())
            {
                return(BadRequest(new { error = "De voorziene token voldoet niet aan de eisen." }));
            }

            if (ModelState.IsValid)
            {
                Company newCompany = new Company
                {
                    Name = companyToAdd.Name
                };

                _companyRepository.addCompany(int.Parse(User.FindFirst("userId")?.Value), newCompany);
                return(Ok(new { bericht = "Het bedrijf werd succesvol toegevoegd." }));
            }
            //Als we hier zijn is is modelstate niet voldaan dus stuur error 400, slechte aanvraag
            string errorMsg = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

            return(BadRequest(new { error = errorMsg }));
        }
        public async Task <IActionResult> AddCompany(AddCompanyViewModel model)
        {
            validationService.ValidateAddCompanyViewModel(model, ModelState);

            if (ModelState.IsValid)
            {
                ContactInfo contactInfo = await companyService.CreateContactInfo(model.ContactInfo);

                RegistrationData registrData = companyService.CreateRegistrationDate(model);
                Company          company     = companyService.CreateCompany(model, registrData, contactInfo);
                companyService.CreateAddress(company, model.FactAddress);
                companyService.CreateAddress(company, model.LegalAddress);
                return(RedirectToAction("RegisterEmployeeCompany", "User", new { companyId = company.Id }));
            }
            else
            {
                model.FactAddress.Countries  = selectListService.GetCountries();
                model.LegalAddress.Countries = selectListService.GetCountries();
                model = selectListService.GetCompaniesSelectList(model);
                return(View(model));
            }
        }