//-------------------------------------------------------RETAILER-------------------------------------------------// public ActionResult RetailerRegistration() { District CT = new Models.District(); ViewBag.dtCT = CT.selectall(); return(View()); }
static private void CopyToInstance(PerformContext performContext, DbAppContext dbContext, HETSAPI.Import.HETS_District oldObject, ref Models.District dis, string systemId) { bool isNew = false; if (dis == null) { isNew = true; dis = new Models.District(); } if (dbContext.Districts.Where(x => x.Name.ToUpper() == oldObject.Name.Trim().ToUpper()).Count() == 0) { isNew = true; dis.Name = oldObject.Name.Trim(); dis.Id = oldObject.District_Id; //dbContext.Districts.Max(x => x.Id) + 1; //oldObject.Seq_Num; dis.MinistryDistrictID = oldObject.Ministry_District_Id; dis.RegionId = oldObject.Region_ID; dis.CreateTimestamp = DateTime.UtcNow; dis.CreateUserid = systemId; } if (isNew) { dbContext.Districts.Add(dis); //Adding the city to the database table of HET_CITY } try { dbContext.SaveChangesForImport(); } catch (Exception e) { performContext.WriteLine("*** ERROR With add or update District ***"); performContext.WriteLine(e.ToString()); } }
public ActionResult FarmerEdit() { District CT = new Models.District(); ViewBag.dtCT = CT.selectall(); return(View()); }
public ActionResult UCView(int?DistrictID, int?TehsilID) { var Districts = db.Districts.ToList(); cityvm.CityList.Clear(); if (DistrictID != null && TehsilID != null) { //SelectedTehsilID = TehsilID; List <Models.Data.UC> UCs = db.UCs.Where(t => t.TehsilID == TehsilID).ToList(); Models.District cd = Districts.Find(p => p.DistrictID == DistrictID); // Models.Tehsil spd = cd.TehsilList.Find(p => p.TehsilID == TehsilID); foreach (Models.Data.UC cpd in UCs) { cityvm.CityList.Add(cpd); } } return(View(cityvm)); }
/// <summary> /// Import Districts /// </summary> /// <param name="performContext"></param> /// <param name="dbContext"></param> /// <param name="fileLocation"></param> /// <param name="systemId"></param> static public void Import(PerformContext performContext, DbAppContext dbContext, string fileLocation, string systemId) { string completed = DateTime.Now.ToString("d") + "-" + "Completed"; ImportMap importMap = dbContext.ImportMaps.FirstOrDefault(x => x.OldTable == oldTable && x.OldKey == completed && x.NewKey == sigId); if (importMap != null) { performContext.WriteLine("*** Importing " + xmlFileName + " is complete from the former process ***"); return; } try { string rootAttr = "ArrayOf" + oldTable; performContext.WriteLine("Processing " + oldTable); var progress = performContext.WriteProgressBar(); progress.SetValue(0); // create serializer and serialize xml file XmlSerializer ser = new XmlSerializer(typeof(HETS_District[]), new XmlRootAttribute(rootAttr)); MemoryStream memoryStream = ImportUtility.memoryStreamGenerator(xmlFileName, oldTable, fileLocation, rootAttr); HETSAPI.Import.HETS_District[] legacyItems = (HETSAPI.Import.HETS_District[])ser.Deserialize(memoryStream); foreach (var item in legacyItems.WithProgress(progress)) { // see if we have this one already. importMap = dbContext.ImportMaps.FirstOrDefault(x => x.OldTable == oldTable && x.OldKey == item.District_Id.ToString()); if (importMap == null) // new entry { Models.District dis = null; CopyToInstance(performContext, dbContext, item, ref dis, systemId); ImportUtility.AddImportMap(dbContext, oldTable, item.District_Id.ToString(), newTable, dis.Id); } else // update { Models.District dis = dbContext.Districts.FirstOrDefault(x => x.Id == importMap.NewKey); if (dis == null) // record was deleted { CopyToInstance(performContext, dbContext, item, ref dis, systemId); // update the import map. importMap.NewKey = dis.Id; dbContext.ImportMaps.Update(importMap); dbContext.SaveChangesForImport(); } else // ordinary update. { CopyToInstance(performContext, dbContext, item, ref dis, systemId); // touch the import map. importMap.LastUpdateTimestamp = DateTime.UtcNow; dbContext.ImportMaps.Update(importMap); dbContext.SaveChangesForImport(); } } } performContext.WriteLine("*** Done ***"); ImportUtility.AddImportMap(dbContext, oldTable, completed, newTable, sigId); } catch (Exception e) { performContext.WriteLine("*** ERROR ***"); performContext.WriteLine(e.ToString()); } }
public void UpdateDistrict(Models.District dc) { userEntities.Entry(dc).State = System.Data.Entity.EntityState.Modified; userEntities.SaveChanges(); }
public void InserDistrict(Models.District dc) { userEntities.Districts.Add(dc); userEntities.SaveChanges(); }