Exemplo n.º 1
0
		public void SaveBranche(BrancheViewModel brancheViewModel, string companyId)
		{
			var company = _clientCompanyManagement.FindById(companyId);

			if (company != null)
			{
				var isNew = brancheViewModel.IsNew;

				if (isNew)
				{
					var branch = new ClientCompanyBranche();
					brancheViewModel.FillModel(branch);
					company.Branches.Add(branch);
				}
				else
				{
					int brancheId;
					Int32.TryParse(brancheViewModel.Id, out brancheId);
					var companyBranch = company.Branches.FirstOrDefault(e => e.Id == brancheId);

					ChangeUserStatusDependingOnBranchStatus(brancheId, brancheViewModel.Status);

					if (companyBranch != null)
					{
						brancheViewModel.FillModel(companyBranch);
					}

				}
			}
		}
Exemplo n.º 2
0
		public BrancheViewModel(ClientCompanyBranche clientCompanyBranche, ClientCompanyStatus companyStatus, string state, bool allowEditStatus, IEnumerable<StatusHistoryViewModel> statusHistory)
		{
			_allowEditStatus = allowEditStatus;
			if (clientCompanyBranche != null)
			{
				Id = clientCompanyBranche.Id.ToString(CultureInfo.InvariantCulture);
				BranchName = clientCompanyBranche.Name;
				if (clientCompanyBranche.Address != null)
				{
					Address = new AddressViewModel
											{
												City = clientCompanyBranche.Address.City,
												State = state,
												Street = clientCompanyBranche.Address.Street,
												Street2 = clientCompanyBranche.Address.Street2,
												ZIP = clientCompanyBranche.Address.ZIP
											};
				}
				BranchContact = clientCompanyBranche.BranchContact;
				ContactEmail = clientCompanyBranche.ContactEmail;
				BranchPhone = clientCompanyBranche.BranchPhone;
				BranchFax = clientCompanyBranche.BranchFax;
				Status = clientCompanyBranche.Status;
				CompanyStatus = companyStatus;
			}

			StatusHistories = statusHistory;
		}
Exemplo n.º 3
0
		public void FillModel(ClientCompanyBranche clientCompanyBranche)
		{
			clientCompanyBranche.Name = BranchName;
			if (clientCompanyBranche.Address == null)
				clientCompanyBranche.Address = new Address();

			clientCompanyBranche.Address.City = Address.City;
			clientCompanyBranche.Address.Street = Address.Street;
			clientCompanyBranche.Address.Street2 = Address.Street2;
			clientCompanyBranche.Address.ZIP = Address.ZIP;

			clientCompanyBranche.Address.SetStateAbriviature(Address.State);
			clientCompanyBranche.BranchContact = BranchContact;
			clientCompanyBranche.ContactEmail = ContactEmail;
			clientCompanyBranche.BranchPhone = BranchPhone;
			clientCompanyBranche.BranchFax = BranchFax;
			clientCompanyBranche.Status = Status;
		}
Exemplo n.º 4
0
		public void GetBranchesCount_should_get()
		{
			var filter = new BranchesFilter
			{
				BranchNamePart = "Branch",
				CompanyId = "companyId"
			};
			var branch = new ClientCompanyBranche
			{
				Name = "Branch",
				StatusId = Enum.GetName(typeof(ClientCompanyStatus), ClientCompanyStatus.Active),
			};
			var branches = new[] { branch };
			var company = new ClientCompany { Branches = branches };
			var companies = new[] { company };
			_clientCompanyManagement.GetCompanies(Arg.Any<Func<IQueryable<ClientCompany>, IQueryable<ClientCompany>>>()).ReturnsForAnyArgs(companies);

			_target.GetBranchesCount(filter).Should().Be(1);
		}
Exemplo n.º 5
0
		public void SaveBranche_should_save_if_branch_is_new()
		{
			var companyId = "companyId";
			var model = new BrancheViewModel
			{
				IsNew = true,
				Address = new AddressViewModel()
			};
			var branch = new ClientCompanyBranche
			{
				Name = "Branch",
				StatusId = Enum.GetName(typeof(ClientCompanyBrancheStatus), ClientCompanyBrancheStatus.Active),
				Address = new Address()
			};
			var branches = new[] { branch }.ToList();
			var company = new ClientCompany { Branches = branches };
			var companies = new[] { company };
			_clientCompanyManagement.GetCompanies(Arg.Any<Func<IQueryable<ClientCompany>, IQueryable<ClientCompany>>>()).ReturnsForAnyArgs(companies);

			_target.SaveBranche(model, companyId);
		}
Exemplo n.º 6
0
		public void SaveBrancheStatus_should_save()
		{
			const string companyId = "companyId";
			const int branchId = 1;
			var branch = new ClientCompanyBranche
			{
				Id = branchId,
				Name = "Branch",
				StatusId = Enum.GetName(typeof(ClientCompanyBrancheStatus), ClientCompanyBrancheStatus.Active),
				Address = new Address()
			};
			var branches = new[] { branch };
			var company = new ClientCompany
			{
				CompanyId = companyId,
				Branches = branches,
				StatusId = Enum.GetName(typeof(ClientCompanyStatus), ClientCompanyStatus.Active),
			};
			var companies = new[] { company };
			_clientCompanyManagement.GetCompanies(Arg.Any<Func<IQueryable<ClientCompany>, IQueryable<ClientCompany>>>()).ReturnsForAnyArgs(companies);
			var model = new BrancheStatusViewModel
			{
				BrancheId = branchId.ToString(CultureInfo.InvariantCulture)
			};

			_target.SaveBrancheStatus(model, companyId);
		}
Exemplo n.º 7
0
		public void GetBranche_should_get()
		{
			const string companyId = "companyId";
			const int branchId = 1;
			var branch = new ClientCompanyBranche
			{
				Id = branchId,
				Name = "Branch",
				StatusId = Enum.GetName(typeof(ClientCompanyBrancheStatus), ClientCompanyBrancheStatus.Active),
				Address = new Address()
			};
			var branches = new[] { branch };
			var company = new ClientCompany
			{
			  CompanyId = companyId,
				Branches = branches,
				StatusId = Enum.GetName(typeof(ClientCompanyStatus), ClientCompanyStatus.Active),
			};
			var companies = new[] { company };
			_clientCompanyManagement.GetCompanies(Arg.Any<Func<IQueryable<ClientCompany>, IQueryable<ClientCompany>>>()).ReturnsForAnyArgs(companies);
			var statuses = new Dictionary<string, string>();
			_referenceManagement.GetAllStates().Returns(statuses);
			
			_target.GetBranche(companyId, branchId.ToString(CultureInfo.InvariantCulture));
		}