private async Task SaveTax(AddOrUpdateTaxCommand request, Municipalities municipalities) { if (request.TaxType == TaxType.Yearly) { await _yearlyTaxRepository.AddTax(new YearlyTax { Municipality = municipalities.Id, Date = Convert.ToDateTime($"{request.Date.Year}/01/01"), Tax = request.Tax }); } else if (request.TaxType == TaxType.Monthly) { await _monthlyTaxRepository.AddTax(new MonthlyTax { Municipality = municipalities.Id, Date = Convert.ToDateTime($"{request.Date.Year}/{request.Date.Month}/01"), Tax = request.Tax }); } else if (request.TaxType == TaxType.Daily) { await _dailyTaxRepository.AddTax(new DailyTax { Municipality = municipalities.Id, Date = request.Date, Tax = request.Tax }); } }
public async Task Should_Save_Municipality(int id, string name, string pointOfContact, string email, string modifiedBy, string createdBy, bool isActive, string nameComparer, int expectedCount, int expectedId) { //Arrange var addressModel = new Domains.Address { Id = id, Address1 = "123 Straight Way", City = "Arlington", State = 17, Zip = "76012" }; var model = new Municipalities { Id = id, Name = name, PointOfContact = pointOfContact, Email = email, AddressId = 1, Address = addressModel }; var countBefore = UsingDbContext(context => { return(context.Municipalities.Count(x => x.IsActive)); }); //Act if (id != 0) { UsingDbContext(context => { var originalData = context.Municipalities.FirstOrDefault(x => x.Id == id); originalData.ShouldNotBeNull(); originalData.Name.ShouldBe(nameComparer); }); } _municipalityService.SaveMunicipality(model); var count = UsingDbContext(context => { return(context.Municipalities.Count()); }); var municipalities = UsingDbContext(context => { return(context.Municipalities.FirstOrDefault(x => x.Id == expectedId)); }); count.ShouldBe(expectedCount); municipalities.ShouldNotBeNull(); municipalities.Name.ShouldBe(name); }
public List <ComboBoxModel> Municipalitiy() { List <ComboBoxModel> result = new List <ComboBoxModel>(); var municipality = Municipalities.GetAll(); result = municipality.Select(s => new ComboBoxModel { id = s.id_municipality, Name = s.Name }).ToList(); return(result); }
private static object GetMunicipality(dynamic _) { try { return(Municipalities.GetByName(_.name.ToString()).ToString()); } catch (Exception e) { return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError)); } }
private static object GetAll(dynamic _) { try { return(Municipalities.GetAll()); } catch (Exception e) { return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError)); } }
public InsertWorkerModel(Guid userId) { var workServ = ServiceLocator.Get <IWorkerService>(); WorkerVO w = workServ.Get(x => x.UserFK == userId); w = workServ.LoadEnumerablesProperties(w); WorkerVO = w; UserVO = w.User; if (UserVO.Municipality != null) { Province = WebNomenclatorsCache.Instance.Provinces.Where(x => x.Id == w.User.Municipality.ProvinciaId).FirstOrDefault(); UserVO.Municipality = Municipalities.Where(x => x.Id == UserVO.Municipality.Id).FirstOrDefault(); } UserClientRole = UserClientRole.Trabajador; //AuthenticationTypes = UserVO.AuthenticationType; SelectedCourses = new ObservableCollection <CourseVO>(w.Courses); SelectedLicenses = new ObservableCollection <DriverLicenseVO>(w.DriverLicenses); SelectedVehicles = new ObservableCollection <VehicleVO>(w.Vehicles); SelectedWorkAspirations = new ObservableCollection <WorkAspirationVO>(w.WorkAspirations); SelectedWorkerLanguages = new ObservableCollection <WorkerLanguageVO>(w.Languages); SelectedWorkReferences = new ObservableCollection <WorkReferenceVO>(w.WorkReferences); WorkerLanguagesSource = (from l in WebNomenclatorsCache.Instance.Languages select new WorkerLanguageVO { Language = new LanguageVO { Id = l.Id, Name = l.Name, }, }).ToList(); var ll = WebNomenclatorsCache.Instance.LanguageLevels.Where(x => x.Name == "Básico").FirstOrDefault(); if (ll == null) { throw new Exception("Error interno"); } foreach (var item in WorkerLanguagesSource) { item.LanguageLevel = ll; item.WorkerFK = WorkerVO.Id; } WorkAspirationsSource = new List <WorkAspirationVO>(); foreach (var item in WebNomenclatorsCache.Instance.Workplaces) { WorkAspirationsSource.Add(new WorkAspirationVO() { WorkerFK = WorkerVO.Id, Workplace = item, }); } }
public MunicipalityModule() : base("/municipality") { var path = "/{name}"; Get("/", _ => GetAll(_)); Get("/name/{name}", _ => GetMunicipality(_)); Post("/add", _ => { try { var model = this.Bind <Municipality>(); Municipalities.Add(model); return(model); } catch (Exception e) { return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError)); } }); }
/// <summary> /// Primært for å hente innholdet i objektet ved logging /// </summary> /// <returns></returns> public override string ToString() { return($"FullPersonInfo: {GetFullPersonInfo}; HistoricalData: {GetHistoricalData}; Municipalities[ {string.Join(", ", Municipalities.Select(c => "MunicipalityId: " + c.CodeValue))}]"); }