private void Fill() { ContractorsLogic contractors = new ContractorsLogic(manager); DataGV.AutoGenerateColumns = false; List <Contractor> resultA = contractors.GetAll(); List <ContractorView> contractorsView = new List <ContractorView>(); foreach (Contractor a in resultA) { ContractorView c = new ContractorView(a, manager); contractorsView.Add(c); } view = new SortableBindingList <ContractorView>(contractorsView); DataGV.DataSource = view; DataGV.AutoResizeRows(); DataGV.Update(); PersonCB.SelectedIndex = 0; ContractorTypesDDL.Items.Clear(); ContractorTypesLogic types = new ContractorTypesLogic(manager); ContractorTypesDDL.DisplayMember = "Name"; ContractorTypesDDL.ValueMember = "ID"; ContractorType all = new ContractorType(); all.ID = -1; all.Name = " - всі - "; ContractorTypesDDL.Items.Add(all); foreach (var a in types.GetAll()) { ContractorTypesDDL.Items.Add(a); } ContractorTypesDDL.SelectedIndex = 0; }
public async Task Handle(AddNewContractorCommand command, IMessageHandlerContext messageContext) { try { var contractorDto = command.Contractor; ContractorStatus status = ContractorStatus.Open; var contractDuration = new DateTimeRange(contractorDto.ContractStartDate, contractorDto.ContractEndDate); var contact = new Contact(new Name(contractorDto.ContactFirstName, contractorDto.ContactLastName), contractorDto.ContactPhoneNumber, contractorDto.ContactAlternatePhoneNumber, contractorDto.ContactEmail); var contractrorAddress = new VO.Address(contractorDto.AddressLine1, contractorDto.AddressLine2, contractorDto.City, contractorDto.StateCode, contractorDto.ZipCode); ContractorType type = contractorDto.Type; var contractorSuffix = _contractorSuffixGenerator.GetContractorSuffixForNewContractor(contractorDto.EinNumber, type); //TODO: User should be sending the GUIDs, leaving it for testing to do auto generated guid var contractor = new Entities.Contractor(contractorDto.EinNumber + contractorSuffix, contractorDto.ContractorName, contractorDto.DoingBusinessAs, status, type, contractDuration, contractorDto.PhoneNumber, contact, contractrorAddress, contractorDto.Email); _contractorRepository.AddContractor(contractor); await _contractorRepository.SaveAsync(); await Task.WhenAll(messageContext.Publish(new CommandCompletedEvent(command.Id, DateTime.UtcNow)), messageContext.Publish(new ContractorAdded(DateTime.Now, contractor.Id, contractor.EinNumber) { ContractorEin = contractor.EinNumber })); } catch (Exception ex) { //TODO: Global Exception logging await messageContext.Publish(new CommandFailedEvent(command.Id, ex, DateTime.UtcNow)); throw; } }
public string GetContractorSuffixForNewContractor(string einSsn, ContractorType type) { ThrowIfInvalidEinSsn(einSsn); if (type == ContractorType.Contracted) { return GenerateContractorSuffixForContractedContractor(einSsn); } else return GenerateContractorSuffixForSelfArrangedContractor(einSsn); }
public void BecauseEnumOutOfRange() { // ARRANGE ContractorType unsupportedEnumValue = 0; // ACT var exception = Fail.BecauseEnumOutOfRange(unsupportedEnumValue); // ASSERT Assert.That(exception.Message, Is.EqualTo("Unsupported enum value: 0 (ContractorType)")); }
public string GetContractorSuffixForNewContractor(string einSsn, ContractorType type) { ThrowIfInvalidEinSsn(einSsn); if (type == ContractorType.Contracted) { return(GenerateContractorSuffixForContractedContractor(einSsn)); } else { return(GenerateContractorSuffixForSelfArrangedContractor(einSsn)); } }
private void Fill() { ContractorTypesLogic types = new ContractorTypesLogic(manager); if (mode == "edit") { ContractorType type = types.Get(Convert.ToInt32(id)); if (type != null) { NameTB.Text = type.Name; } } }
private DadataResponse GetSuggestionsInternal(string query, ContractorType type) { var request = (HttpWebRequest)WebRequest.Create(_dadataUrl); request.Method = WebRequestMethods.Http.Post; request.ContentType = "application/json"; request.Accept = "application/json"; request.Headers.Add("Authorization", $"Token {_apiKey}"); var requestJson = JsonConvert.SerializeObject(new DadataRequest(query, type)); HttpWebResponse response = null; try { request.ContentLength = requestJson.Length; using (Stream stream = request.GetRequestStream()) stream.Write(Encoding.UTF8.GetBytes(requestJson), 0, requestJson.Length); response = (HttpWebResponse)request.GetResponse(); string responseJson; using (var sr = new StreamReader(response.GetResponseStream())) responseJson = sr.ReadToEnd(); if (response.StatusCode == HttpStatusCode.OK && !responseJson.IsNullOrEmpty()) { DadataResponse dadataResponse = JsonConvert.DeserializeObject <DadataResponse>(responseJson); if (dadataResponse.Suggestions.Length == 0) { return(null); } return(dadataResponse); } } catch (WebException ex) { // TODO } catch (Exception ex) { // TODO } finally { response?.Close(); } return(null); }
public void CastEnumOrFail2() { // ARRANGE ContractorType enumValue = 0; // ACT var exception = Assert.Throws <DesignByContractViolationException>( () => enumValue.CastEnumOrFail <ContractorType>(nameof(enumValue)) ); // ASSERT Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.EqualTo("Unsupported enumValue value: 0 (ContractorType)")); //Assert.That(enumValue, Is.EqualTo(ContractorType.Company)); }
public Contractor(Guid id, string einNumber, string contractorName, string doingBusinessAs, ContractorStatus status, ContractorType type, DateTimeRange contractDuration, PhoneNumber primaryPhoneNumber, Contact contactDetails, VO.Address address, string email) : base(id) { //TODO: Implement guard conditions Id = id; EinNumber = einNumber; ContractorName = contractorName; DoingBusinessAs = doingBusinessAs; Status = status; ContractorType = type; ContractDuration = contractDuration; PhoneNumber = primaryPhoneNumber; Contact = contactDetails; Address = address; Email = email; InitializeState(); }
public Contractor(Guid id, string einNumber, string contractorName, string doingBusinessAs, ContractorStatus status, ContractorType type, DateTimeRange contractDuration, PhoneNumber primaryPhoneNumber, Contact contactDetails,VO.Address address, string email) : base(id) { //TODO: Implement guard conditions Id = id; EinNumber = einNumber; ContractorName = contractorName; DoingBusinessAs = doingBusinessAs; Status = status; ContractorType = type; ContractDuration = contractDuration; PhoneNumber = primaryPhoneNumber; Contact = contactDetails; Address = address; Email = email; InitializeState(); }
public DadataResponse GetSuggestions(string inn, string kpp, ContractorType type) { DadataResponse response = null; // При создании контрагента проверять его наличие в ЕГРЮЛ по полям inn kpp для Юр.лица и по inn для ИП if (type == ContractorType.Legal) { response = GetSuggestionsInternal(inn, type); if (response == null) { response = GetSuggestionsInternal(kpp, type); } } else if (type == ContractorType.Individual) { response = GetSuggestionsInternal(inn, type); } return(response); }
public ActionResult Delete(int id) { try { ContractorType contractorType = new ContractorType() { keyId = id }; using (var context = new DbEntities()) { context.ContractorType.Attach(contractorType); context.ContractorType.Remove(contractorType); context.SaveChanges(); } return(RedirectToAction("Index", "DataTypes")); } catch { return(RedirectToAction("Index", "DataTypes")); } }
public ActionResult Add() { var model = GetModelFromJson(); try { using (var context = new DbEntities()) { ContractorType NewContratorType = new ContractorType { Name = model.name }; context.ContractorType.Add(NewContratorType); context.SaveChanges(); } } catch { return(RedirectToAction("Index", "DataTypes")); } return(RedirectToAction("Index", "DataTypes")); }
public List <string> GetContractorEinsStartingWith(string einSsn, ContractorType type) { var contractorType = type.Value; return(_dbContext.Contractor.Where(x => x.EinNumber.StartsWith(einSsn) && x.Type == contractorType).Select(x => x.EinNumber).ToList()); }
public Contractor(string einNumber, string contractorName, string doingBusinessAs, ContractorStatus status, ContractorType type, DateTimeRange contractDuration, PhoneNumber primaryPhoneNumber, Contact contactDetails, VO.Address address, string email) : this(GuidHelper.NewSequentialGuid(), einNumber, contractorName, doingBusinessAs, status, type, contractDuration, primaryPhoneNumber, contactDetails, address, email) { }
public List<string> GetContractorEinsStartingWith(string einSsn, ContractorType type) { var contractorType = type.Value; return _dbContext.Contractor.Where(x => x.EinNumber.StartsWith(einSsn) && x.Type == contractorType).Select(x => x.EinNumber).ToList(); }
public DadataRequest(string query, ContractorType contractorType) { Query = query; Type = contractorType == ContractorType.Legal ? "LEGAL" : "INDIVIDUAL"; }