private List <CountryPerson> GetCountryPerson(List <InsertExeclCountryPerson> insertExeclCountryPersonList, CountryImportExcel request, int checkCount) { var countryPersonList = new List <CountryPerson>(); if (!CheckInserExecl(insertExeclCountryPersonList)) { return(null); } else { foreach (var insertExecl in insertExeclCountryPersonList) { var countryPerson = new CountryPerson(); if (!string.IsNullOrEmpty(insertExecl.UserName) && !string.IsNullOrEmpty(insertExecl.Phone) && !string.IsNullOrEmpty(insertExecl.Postion)) { countryPerson.UserName = insertExecl.UserName; countryPerson.Position = insertExecl.Postion; countryPerson.Post = insertExecl.Post; countryPerson.Remark = insertExecl.Remark; countryPerson.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); countryPerson.CreateName = insertExecl.UserName; countryPerson.Phone = insertExecl.Phone; countryPerson.UpdateName = insertExecl.UserName; countryPerson.Year = request.year; countryPerson.Country = RealName; countryPerson.adcd = adcd; countryPerson.AuditNums = checkCount; countryPerson.UpdateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); countryPersonList.Add(countryPerson); } else { return(null); } } return(countryPersonList); } }
public async Task <IActionResult> About() { ViewData["Message"] = "Application For Applying As A Teacher"; using (var context = new ApplicationDbContext()) { Random rnd = new Random(); UInt16 year = (UInt16)rnd.Next(1999, 2017); JobCircular jobCircular = context.JobCirculars .SingleOrDefault(j => j.Id == 1); Address presentAddress = new Address { HoldingNoOrVillage = "1234", RoadBlockSector = "28", Thana = "Kotawoli", PostOffice = "Rupatoli", District = "Barisal" }; Address permanentAddress = new Address { HoldingNoOrVillage = "86/3", RoadBlockSector = "2 No Cross Road", Thana = "Daulatpur", PostOffice = "Daulatpur", District = "Khulna" }; ICollection <Experience> experiences = new List <Experience>(); for (int i = 0; i < 4; i++) { Experience experience = new Experience { NameOfPost = i.ToString(), NameOfOrganization = i.ToString(), OrganizationType = OrganizationType.Government, SalaryScale = (UInt16)rnd.Next(1999, 2017), TotalSalary = (UInt16)rnd.Next(1999, 2017), StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow }; experiences.Add(experience); } Person person = new Person { ProfileImageFileUrl = "asd asd asd asd asd sadas dasd asd", BengaliName = "a sdasd asd asd asd asd", EnglishName = "Asasd asd asd asd asd", NickName = "Rs dsd fsdaf sdf sdf", PhoneNumber = "+8801822804636", Email = "*****@*****.**", FatherName = "asd asd asd asd", DateOfBirth = DateTime.UtcNow, PresentAddress = presentAddress, PermanentAddress = permanentAddress, Nationality = "Bangladeshi", MaritalStatus = IsMarried.Unmarried, Religion = ReligionName.Islam, NId = 1000000009, IsInvolvedWithAnyAssociation = Decision.No, IsEverSuspended = Decision.No, Experiences = experiences }; Payment payment = new Payment { BankDraftOrPayOrderNo = "", DateOfDraftOrOrder = DateTime.UtcNow, AmountOfMoney = 10, NameOfBank = "asd asd asd", BranchOfBank = "Asdas dasd asd a" }; TeacherApplication teacherApplication = new TeacherApplication { JobCircular = jobCircular, Person = person, AgeAtLastDateOfSubmission = jobCircular.EndDate - person.DateOfBirth, HasContactWithAnyOrganization = Decision.No, IsGettingPension = Decision.No, Payment = payment }; for (int i = 1; i < 4; i++) { Country country = context.Countries .SingleOrDefault(c => c.Id == i); CountryPerson countryPerson = new CountryPerson { Country = country, Person = person, ReasonOfTour = i.ToString() }; context.CountryPersons.Add(countryPerson); } context.TeacherApplications.Add(teacherApplication); await context.SaveChangesAsync(); } return(View()); }
public bool SaveCountryPerson(SaveCountryPerson requset) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(adcd)) { throw new Exception("请重新登录"); } if (!ValidatorHelper.IsMobile(requset.Mobile)) { throw new Exception("手机号码输入错误,请重新输入"); } var info = new CountryPerson(); var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; if (requset.Id != 0) { info.Id = requset.Id; //log.operateMsg = "更新" + requset.name + "的镇级责任人信息"; } //else //{ // var model = GetCountryPersonInfo(requset.name); // if (model != null) // throw new Exception("已存在"); // //log.operateMsg = "新增" + requset.name + "的镇级责任人信息"; //} info.UserName = requset.name; info.CreateTime = DateTime.Now; info.Phone = requset.Mobile; info.Position = requset.Position; info.Post = requset.Post; info.Year = DateTime.Now.Year; info.Remark = requset.Remark; info.Country = RealName; info.UpdateName = requset.name; info.UpdateTime = DateTime.Now; info.CreateName = requset.name; info.adcd = adcd; var oldInfo = db.Single <CountryPerson>(x => x.Id == requset.Id); if (requset.Id != 0) { info.AuditNums = oldInfo.AuditNums + 1; info.OldData = JsonTools.ObjectToJson(oldInfo); info.NewData = JsonTools.ObjectToJson(info); #region 日志 try { var adcdInfo = db.Single <ADCDInfo>(w => w.adcd == oldInfo.adcd); StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/县级防汛防台责任人}下,更新数据{"); sb.Append("县级adcd:" + adcdInfo.adnm + ""); sb.Append("姓名:" + oldInfo.UserName + ""); sb.Append("创建的时间:" + oldInfo.CreateTime + ""); sb.Append("电话:" + oldInfo.Phone + ""); sb.Append("岗位:" + oldInfo.Position + ""); sb.Append("职务:" + oldInfo.Post + ""); sb.Append("年份:" + oldInfo.Year + ""); sb.Append("标记:" + oldInfo.Remark + ""); sb.Append("县的名字:" + oldInfo.Country + ""); sb.Append("更改人的名字:" + oldInfo.UpdateName + ""); sb.Append("更改的时间:" + oldInfo.UpdateTime + ""); sb.Append("创建的人:" + oldInfo.CreateName + ""); sb.Append("}为{"); sb.Append("县级adcd:" + adcdInfo.adnm + ""); sb.Append("姓名:" + info.UserName + ""); sb.Append("创建的时间:" + info.CreateTime + ""); sb.Append("电话:" + info.Phone + ""); sb.Append("岗位:" + info.Position + ""); sb.Append("职务:" + info.Post + ""); sb.Append("年份:" + info.Year + ""); sb.Append("标记:" + info.Remark + ""); sb.Append("县的名字:" + info.Country + ""); sb.Append("更改人的名字:" + info.UpdateName + ""); sb.Append("更改的时间:" + info.UpdateTime + ""); sb.Append("创建的人:" + info.CreateName + ""); sb.Append("}"); logHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); }catch (Exception ex) { } #endregion //"select * from CountryPerson where Phone='" + info.Phone + "' and Position='" + info.Position + "' and UserName='******' and " var r = db.Single <CountryPerson>(w => w.Phone == requset.Mobile && w.Position == info.Position && w.UserName == info.UserName && w.Remark == info.Remark && w.Post == info.Post); if (r != null) { return(false); } else { return(db.Update(info) == 1); } } else { int count; var list = db.Select <AuditCounty>("select * from dbo.AuditCounty where CountyADCD='" + adcd + "' "); if (list.Count == 0) { count = 1; } else { count = Convert.ToInt32(list[0].AuditNums) + 1; } info.AuditNums = count; info.OldData = ""; info.NewData = ""; #region 日志 try { StringBuilder sb = new StringBuilder(); var adcdInfo = db.Single <ADCDInfo>(w => w.adcd == info.adcd); sb.Append("在栏目{组织责任/县级防汛防台责任人}下,新增数据{"); sb.Append("县级adcd:" + adcdInfo.adnm + ""); sb.Append("姓名:" + info.UserName + ""); sb.Append("创建的时间:" + info.CreateTime + ""); sb.Append("电话:" + info.Phone + ""); sb.Append("岗位:" + info.Position + ""); sb.Append("职务:" + info.Post + ""); sb.Append("年份:" + info.Year + ""); sb.Append("标记:" + info.Remark + ""); sb.Append("县的名字:" + info.Country + ""); sb.Append("更改人的名字:" + info.UpdateName + ""); sb.Append("更改的时间:" + info.UpdateTime + ""); sb.Append("创建的人:" + info.CreateName + ""); sb.Append("}"); logHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); }catch (Exception ex) { } #endregion if (db.Select <CountryPerson>("select * from CountryPerson where Phone='" + info.Phone + "' and Position='" + info.Position + "' and UserName='******'").ToList().Count == 1) { return(false); } else { return(db.Insert(info) == 1); } } } }