public IView GetDemo(DemoDetails details) { var demo = demos.GetDemoById(details.Id); return new DemographyView(demo, adminLevel, details.CanViewEdit); }
public void Delete(DemoDetails demo, int userId) { OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString); using (connection) { connection.Open(); try { OleDbCommand command = new OleDbCommand(@"UPDATE AdminLevelDemography SET IsDeleted=@IsDeleted, UpdatedById=@UpdatedById, UpdatedAt=@UpdatedAt WHERE ID=@id", connection); command.Parameters.Add(new OleDbParameter("@IsDeleted", true)); command.Parameters.Add(new OleDbParameter("@UpdatedById", userId)); command.Parameters.Add(OleDbUtil.CreateDateTimeOleDbParameter("@UpdatedAt", DateTime.Now)); command.Parameters.Add(new OleDbParameter("@id", demo.Id)); command.ExecuteNonQuery(); } catch (Exception) { throw; } } }
public void Delete(DemoDetails details, int userId) { SettingsRepository settings = new SettingsRepository(); var type = settings.GetAdminLevelTypeByLevel(adminLevel.LevelNumber); demos.Delete(details, userId); if (type.IsAggregatingLevel) demos.AggregateUp(type, details.DateReported, userId, null, null); }
private AdminLevelDemography SplitDemo(List<AdminLevelDemography> toMerge, DemoDetails details, int destId, double multiplier, int redistrictId, OleDbCommand command, OleDbConnection connection) { var demography = demoRepo.GetDemoById(details.Id); // make new var newDemography = Util.DeepClone(demography); if (newDemography.AdminLevelId != destId) { newDemography.Id = 0; newDemography.AdminLevelId = destId; } if (newDemography.Pop0Month.HasValue) newDemography.Pop0Month = (int)Math.Round((double)demography.Pop0Month * multiplier); if (newDemography.PopPsac.HasValue) newDemography.PopPsac = (int)Math.Round((double)demography.PopPsac * multiplier); if (newDemography.Pop5yo.HasValue) newDemography.Pop5yo = (int)Math.Round((double)demography.Pop5yo * multiplier); if (newDemography.PopAdult.HasValue) newDemography.PopAdult = (int)Math.Round((double)demography.PopAdult * multiplier); if (newDemography.PopFemale.HasValue) newDemography.PopFemale = (int)Math.Round((double)demography.PopFemale * multiplier); if (newDemography.PopMale.HasValue) newDemography.PopMale = (int)Math.Round((double)demography.PopMale * multiplier); if (newDemography.TotalPopulation.HasValue) newDemography.TotalPopulation = (int)Math.Round((double)demography.TotalPopulation * multiplier); if (newDemography.PopSac.HasValue) newDemography.PopSac = (int)Math.Round((double)demography.PopSac * multiplier); // save if (toMerge == null) { demoRepo.SaveAdminDemography(command, connection, newDemography, userId); demoRepo.InsertRedistrictForm(command, connection, userId, redistrictId, demography.Id, newDemography.Id, IndicatorEntityType.Demo); } else toMerge.Add(newDemography); return newDemography; }