public IActionResult GetInvoice(int id) { var order = OrdersRepo.Get(id); var invoice = InvoiceGenerator.GenerateInvoice(order, FeeRepository.Get()); return(new FileContentResult(Encoding.UTF8.GetBytes(invoice), InvoiceGenerator.MediaType)); }
public void ListFeeSuccessfully() { var content = File.ReadAllText("../../../Fixtures/fees_list.json"); var client = GetMockClient(content); var repo = new FeeRepository(client.Object); var fees = repo.ListFees(); Assert.IsNotNull(fees); Assert.IsTrue(fees.Any()); }
public void GetFeeByIdSuccessfull() { var content = File.ReadAllText("../../Fixtures/fees_get_by_id.json"); var client = GetMockClient(content); var repo = new FeeRepository(client.Object); const string id = "79116c9f-d750-4faa-85c7-b7da36f23b38"; var fee = repo.GetFeeById(id); Assert.AreEqual(id, fee.Id); }
public void GetFeeByIdSuccessfull() { var content = File.ReadAllText("../../../Fixtures/fees_get_by_id.json"); var client = GetMockClient(content); var repo = new FeeRepository(client.Object); const string id = "79116c9f-d750-4faa-85c7-b7da36f23b38"; var response = repo.GetFeeById(id); var fee = JsonConvert.DeserializeObject <IDictionary <string, object> >(JsonConvert.SerializeObject(response.Values.First())); Assert.AreEqual(id, (string)fee["id"]); }
public void CreateFeeWrongTo() { var client = GetMockClient(""); var repo = new FeeRepository(client.Object); var feeId = Guid.NewGuid().ToString(); Assert.Throws <ValidationException>(() => repo.CreateFee(new Fee { Id = feeId, Amount = 1000, Name = "Test fee #1", FeeType = FeeType.Fixed, Cap = "1", Max = "3", Min = "2", })); }
public void CreateFeeWrongTo() { var client = GetMockClient(""); var repo = new FeeRepository(client.Object); var feeId = Guid.NewGuid().ToString(); Assert.Throws <ValidationException>(() => repo.CreateFee(new Dictionary <string, object> { { "id", feeId }, { "amount", "1000" }, { "name", "Test fee #1" }, { "fee_type_id", "1" }, { "cap", "1" }, { "max", "3" }, { "min", "2" }, { "to", "" } })); }
public void CreateFeeSuccessfully() { var content = File.ReadAllText("../../../Fixtures/fees_create.json"); var client = GetMockClient(content); var repo = new FeeRepository(client.Object); var feeId = Guid.NewGuid().ToString(); var createdFee = repo.CreateFee(new Dictionary <string, object> { { "id", feeId }, { "amount", "1000" }, { "name", "Test fee #1" }, { "fee_type_id", "1" }, { "cap", "1" }, { "max", "3" }, { "min", "2" }, { "to", "buyer" } }); Assert.IsNotNull(createdFee); }
public void CreateFeeSuccessfully() { var content = File.ReadAllText("../../Fixtures/fees_create.json"); var client = GetMockClient(content); var repo = new FeeRepository(client.Object); var feeId = Guid.NewGuid().ToString(); var createdFee = repo.CreateFee(new Fee { Id = feeId, Amount = 1000, Name = "Test fee #1", FeeType = FeeType.Fixed, Cap = "1", Max = "3", Min = "2", To = "buyer" }); Assert.IsNotNull(createdFee); }
public IEnumerable <OrderDto> Get() { return(OrdersRepo.Get(CustomersRepository.GetCurrentCustomer()).Select(o => o.ToOrderDto(FeeRepository.Get()))); }
public async Task <PlanningApp> Create(CreatePlanningAppResource planningResource) { var planningApp = Mapper.Map <CreatePlanningAppResource, PlanningApp>(planningResource); //Use when gui setup to create multiple generators //planningApp.ProjectGenerator = ProjectGeneratorRepository.GetProjectGenerator(planningResource.ProjectGeneratorId).Result; //Console.WriteLine("Creating New Planning App, Project Generator -> " + planningApp.ProjectGenerator.Name); //Dummy project multi generator for now planningApp.ProjectGeneratorId = planningResource.ProjectGeneratorId; planningApp.StartDate = SystemDate.Instance.date; //Create Customer planningApp.Customer = CustomerRepository.GetCustomer(planningResource.CustomerId).Result; //Set Status planningApp.CurrentPlanningStatus = statusList.Where(s => s.Name == StatusList.AppInProgress).SingleOrDefault(); //Create States planningApp = await AddSingleGeneratorStates(planningApp); Console.WriteLine("Generated " + planningApp.PlanningAppStates.Count + " Planning States"); //Refactor!!!!!!! if (planningResource.Surveyors != null) { foreach (string surveyorId in planningResource.Surveyors) { PlanningAppSurveyors planningAppSurveyors = new PlanningAppSurveyors(); planningAppSurveyors.PlanningApp = planningApp; planningAppSurveyors.AppUser = await UserManager.FindByIdAsync(surveyorId); planningApp.Surveyors.Add(planningAppSurveyors); } } if (planningResource.Drawers != null) { foreach (string surveyorId in planningResource.Drawers) { PlanningAppDrawers planningAppDrawers = new PlanningAppDrawers(); planningAppDrawers.PlanningApp = planningApp; planningAppDrawers.AppUser = await UserManager.FindByIdAsync(surveyorId); planningApp.Drawers.Add(planningAppDrawers); } } if (planningResource.Admins != null) { foreach (string adminId in planningResource.Admins) { PlanningAppAdmins planningAppAdmins = new PlanningAppAdmins(); planningAppAdmins.PlanningApp = planningApp; planningAppAdmins.AppUser = await UserManager.FindByIdAsync(adminId); planningApp.Admins.Add(planningAppAdmins); } } //Create Fees foreach (var fee in FeeRepository.GetFeesDefault()) { PlanningAppFees planningAppFees = new PlanningAppFees { Amount = fee.DefaultAmount, Fee = fee }; planningApp.Fees.Add(planningAppFees); } //Persist planning app PlanningAppRepository.Add(planningApp); await UnitOfWork.CompleteAsync(); //Create Reference using planning id planningApp.PlanningReferenceId = genCustomerReferenceId(planningApp); PlanningAppRepository.UpdatePlanningApp(planningApp); await UnitOfWork.CompleteAsync(); //Retrieve planning app from database and return results to controller return(await PlanningAppRepository.GetPlanningApp(planningApp.Id, includeRelated : false)); }
public FeeController() { _feeRepository = new FeeRepository(); }