//分页得到经理页面 public List<Firm> GetFirmViewByPage(MyPage page) { page.CountPerPage = 10; page.WholePage = (int)data.getFirmViewPageCount(page.CountPerPage); var table = data.getFirmViewByPage(page.CurrentPage, page.CountPerPage); List<Firm> firms = new List<Firm>(); foreach (var col in table) { Firm firm = new Firm(); firm.FirmAddress = col.firm_address; firm.FirmID = col.firm_id; firm.FirmName = col.firm_name; firm.HostCount = (int)col.host_count; firm.TaxiCount = (int)col.taxi_count; firm.PhoneNumber = col.phone_number; firm.DriverCount = (int)col.driver_count; firms.Add(firm); } return firms; }
public Firm GetFirm(long FirmId) { try { using (DataContext = new DmsDomainContext()) { Firm objFirm = new Firm(); objFirm = DataContext.Firms.Where(x => x.FirmId == FirmId).Include(y => y.Users).FirstOrDefault(); return(objFirm); } } catch (Exception ex) { throw; } }
private void SetProperties(Firm firm, TrucksReserveEntities dbModel) { firm.ExcIfNull(); this.ID = firm.ID; this.Name = firm.Name; this.Description = firm.Description.GetTrimmed(); this.Website = firm.Website.GetTrimmed(); Images = new List <BImage>(); if (dbModel != null) { List <Gallery> images = dbModel.Gallery.Where(i => i.Type == (int)ImageType.Firm && i.TypeID == firm.ID).ToList(); if (images.AreThereItems() == true) { this.Images = images.ConvertAll <BImage>(new Converter <Gallery, BImage>(BImage.ElementConverter)); } } }
private void EditFirm() { if (lvFirms.Items == null || lvFirms.Items.Count == 0) { return; } Firm data = null; if (lvFirms.SelectedItems == null || lvFirms.SelectedItems.Count == 0) { lvFirms.Items[0].Selected = true; data = (Firm)lvFirms.Items[0].Tag; } else { data = (Firm)lvFirms.SelectedItems[0].Tag; } var obj = FirmEditorForm.EditFirm(data); if (obj != null) { for (var i = 0; i < DataManager.Firms.Count; i++) { if (DataManager.Firms[i].Id == obj.Id) { DataManager.Firms[i] = obj; break; } } DataManager.SaveFirm(); for (var i = 0; i < lvFirms.Items.Count; i++) { if (((Firm)lvFirms.Items[i].Tag).Id == obj.Id) { lvFirms.Items[i] = CreateListViewItem(obj); break; } } } }
public void AddSearchQueryToLog(string searchQuery, string searchLocation, int queriedFirmId, PropertyType propertyType, int resultInFirm, int resultInOtherFirms) { var firm = _db.Firms.FirstOrDefault(m => m.Id == queriedFirmId); if (firm == null) { firm = new Firm(); } var searchLog = new SearchQueryLog { SearchQuery = searchQuery, SearchLocation = searchLocation, QueriedFirm = firm.Name, PropertyType = propertyType, CountResultFoundInQueriedFirm = resultInFirm, CountResultFoundInOtherFirms = resultInOtherFirms, DateQueried = DateTime.Now }; SaveSearchQueryToDb(searchLog); }
private void newFirmToolStripMenuItem_Click(object sender, EventArgs e) { try { if (frmFirm == null || frmFirm.IsDisposed) { frmFirm = new Firm(); frmFirm.Show(); frmFirm.MdiParent = this; } else { frmFirm.Activate(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main(string[] args) { Console.WriteLine("Получение настроек программы . . ."); Settings settings = Settings.Load(Path.Combine(Environment.CurrentDirectory, "settings.ini")); Console.WriteLine($"Сегодня на смене {settings.OperatorsCount} операторов, {settings.ManagersCount} менеджеров и 1 директор"); Firm firm = new Firm(settings.OperatorsCount, settings.ManagersCount, (settings.CallTimeFinish + settings.CallTimeStart) / 2.0); CallReceiver callReceiver = new CallReceiver(settings.CallTimeStart, settings.CallTimeFinish, settings.CallRespawnStart, settings.CallRespawmFinish); CallBroker callBroker = new CallBroker(firm, callReceiver); //отдельная таска для генерирования звонков Task callReceiverTask = new Task(() => callReceiver.Work()); callReceiverTask.Start(); while (true) { callBroker.Work(); } }
public string GenerateToken(Firm userData) { //generate token var tokenKey = _config.GetSection("BlobSettings").GetValue <String>("AccessKey"); var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(tokenKey); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, userData.Email) }), Expires = DateTime.Now.AddDays(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); var tokenString = tokenHandler.WriteToken(token); return(tokenString); }
static void Main(string[] args) { // StreamWriter writer = new StreamWriter(@"C:\Users\N10\Desktop\PE_PROJECT_UPDATE1\PE_PROJECT\PE_PROJECT\outputFile.txt"); string test = @"C:\Users\N10\Desktop\PE_PROJECT_UPDATE1\PE_PROJECT\PE_PROJECT\outputFile.txt"; File.WriteAllText(test, String.Empty); var oStream = new FileStream(test, FileMode.Append, FileAccess.Write, FileShare.Read); var iStream = new FileStream(test, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); var sw = new System.IO.StreamWriter(oStream); var sr = new System.IO.StreamReader(iStream); Console.WriteLine("Lets create the firm"); Console.WriteLine("Firm Name"); string name = Console.ReadLine(); Console.WriteLine("Firm type"); string type = Console.ReadLine(); Console.WriteLine("Register with dds"); Console.WriteLine("Yes/No"); bool isRegistered = false; string registerResult = Console.ReadLine(); if (registerResult == "Yes") { isRegistered = true; } else { isRegistered = false; } IFirm firm = new Firm(name, type, isRegistered); seedDeps(firm); seedEmployees(firm); Engine engine = new Engine(); engine.Execute(firm, sw, sr); }
public bool Create(Firm firm) { conn = new SqlConnection(connectionString); conn.Open(); string insert = "INSERT INTO Firm (name) VALUES (@name)"; SqlCommand cmd = new SqlCommand(insert, conn); cmd.Parameters.AddWithValue("@name", firm.Name); var retVal = cmd.ExecuteNonQuery(); conn.Close(); if (retVal == 1) { return(true); } return(false); }
public ActionResult Edit(Firm firm) { try { if (ModelState.IsValid) { firmData.Update(firm); firmData.Commit(); return(RedirectToAction(nameof(Index))); } else { return(View(firm)); } } catch { return(View()); } }
public bool Update(int id, Firm firm) { conn = new SqlConnection(connectionString); conn.Open(); string update = "UPDATE Firm SET name = @name WHERE id = @id"; SqlCommand cmd = new SqlCommand(update, conn); cmd.Parameters.AddWithValue("@name", firm.Name); cmd.Parameters.AddWithValue("@id", id); var retVal = cmd.ExecuteNonQuery(); conn.Close(); if (retVal == 1) { return(true); } return(false); }
public ActionResult Create([Bind(Include = "StartDate,EndDate,Description,City,PositionsAvailable,InternshipPostPhoto,Category,Title")] Internship internship) { if (ModelState.IsValid) { string guid = Guid.NewGuid().ToString(); internship.InternshipId = guid; var userId = Session["UserId"].ToString(); Recruiter recruiter = db.Recruiters.Where(a => a.UserId == userId).FirstOrDefault(); Firm firm = recruiter.Firm; internship.FirmOrganizerId = firm.FirmId; internship.RecruiterResponsibleId = recruiter.RecruiterId; db.Internships.Add(internship); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FirmOrganizerId = new SelectList(db.Firms, "FirmId", "Name", internship.FirmOrganizerId); ViewBag.InternshipPostPhoto = new SelectList(db.Images, "Id", "Name", internship.InternshipPostPhoto); ViewBag.RecruiterResponsibleId = new SelectList(db.Recruiters, "RecruiterId", "Name", internship.RecruiterResponsibleId); return(View(internship)); }
public async Task <IActionResult> Create([Bind("CompanyName,UNP,Phone,Adress,ClientStatus")] Firm firm) { try { if (ModelState.IsValid) { _context.Add(firm); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { ModelState.AddModelError("", "Невозможно сохранить данные. " + "Попробуйте снова. Если проблема останется" + "обратитесь к администратору."); } return(View(firm)); }
public void InvalidSessionCache() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Company), typeof(Client), typeof(Firm), typeof(Person)); Recreate(); Company.DeleteAll(); Client.DeleteAll(); Firm.DeleteAll(); Person.DeleteAll(); Firm firm = new Firm("keldor"); Client client = new Client("castle", firm); Company company = new Company("vs"); using (new SessionScope()) { firm.Save(); client.Save(); company.Save(); } using (new SessionScope()) { try { Client c = Client.Find(firm.Id); Assert.Fail("Exception was expected"); } catch (Exception) { // Phew!! } Firm firm2 = Firm.Find(firm.Id); Assert.IsNotNull(firm2); } }
private void button11_Click(object sender, EventArgs e) { using (KPgamenotebookContext db = new KPgamenotebookContext()) { string a = Convert.ToString(comboBox5.SelectedItem); int id = db.Firm.FirstOrDefault(r => r.Name_firm == a).ID_firm; foreach (Model u in db.Model) { if (u.ID_firm == id) { u.ID_firm = null; } } db.SaveChanges(); foreach (Firm u in db.Firm) { if (u.ID_firm == id) { db.Firm.Remove(u); } } db.SaveChanges(); Firm header = new Firm(); header.ID_firm = id; header.Name_firm = textBox10.Text; string name = textBox10.Text; db.Firm.Add(header); db.SaveChanges(); int id2 = db.Firm.FirstOrDefault(r => r.Name_firm == name).ID_firm; foreach (Model u in db.Model) { if (u.ID_firm == null) { u.ID_firm = id2; } } db.SaveChanges(); WriteALL(); } }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new Firm { UserName = Input.UserName, Email = Input.Email, FirmName = Input.FirmName }; var result = await _userManager.CreateAsync(user, Input.Password); await _userManager.AddToRoleAsync(user, "Firm"); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public IActionResult Put([FromBody] Firm payload) { return(NewMethod(payload)); IActionResult NewMethod(Firm payload) { try { using (var conn = new SQLiteConnection(conStr)) { conn.Open(); // bağlantıyı aç // UPDATE cümleciğini çalıştır // Parametreler diğer metodlarda olduğu gibi @ sembolü ile başlayan kelimelerden oluşuyor // Bu parametrelere değer atarken anonymous type de kullanabiliyoruz. //TODO Aslında gelen JSON içeriğinde hangi alanlar varsa sadece onları güncellemeye çalışalım var result = conn.Execute(@"UPDATE FIRM SET NAME=@firmName,CITY=@firmCity,SALARY=@firmSalary WHERE ID=@firmId", new { firmName = payload.Name, firmCity = payload.City, firmSalary = payload.Salary, firmId = payload.ID }); if (result == 1) { return(Ok(payload)); // Eğer güncelleme sonucu 1 ise (ki ID bazlı güncelleme olduğundan 1 dönmesini bekliyoruz) HTTP 200 } else { return(NotFound()); // ID değerinde bir firma yoksa HTTP 404 } } } catch (SQLiteException) // Olası bir SQLite exception durumunda HTTP 400 Bad Request hatası verip içerisine exception mesajını gömüyoruz { return(BadRequest()); // HTTP 400 } } }
public List <Firm> mappingMailAddress() { if (FirmList != null) { List <MailAddress> mailAddressListLR = getMatchedMailListLefToRight(); List <MailAddress> mailAddressListRL = getMatchedMailListRightToLeft(); AllMatchedMailObjectsList = mailAddressListLR; foreach (var item in mailAddressListRL) { AllMatchedMailObjectsList.Add(item); } List <MailAddress> distinctWebList = GetDistinctMailObjectList(); List <Firm> resultFirmList = new List <Firm>(); foreach (var firm in FirmList) { Firm newFirm = firm; foreach (var item in distinctWebList) { if (item.FirmNameValue.Equals(newFirm.firmName)) { newFirm.firmMail = item.MailValue; } } resultFirmList.Add(newFirm); } return(resultFirmList); } else { return(FirmList); } }
public static Firm GetFirm() { Firm firm = new Firm(); GetAllFirmModulesForNewUserDAL objGetFirm = new GetAllFirmModulesForNewUserDAL(); try { try { firm = objGetFirm.GetFirm(CommonENT.MYCTSDBSECURITY_CONNECTION); } catch { firm = objGetFirm.GetFirm(CommonENT.MYCTSDBSECURITYBACKUP_CONNECTION); } } catch { } return(firm); }
public ActionResult Edit([Bind(Include = "Id,Address,Name,Code,EIK")] Firm firm) { var found = db.Firms.Where(f => f.EIK == firm.EIK && f.Id != firm.Id).FirstOrDefault(); if (found != null) { ModelState.AddModelError("EIK", "EIK already exists!!!"); } if (!this.IsRealEIK(firm.EIK)) { ModelState.AddModelError("EIK", "EIK is fake!!!"); } if (ModelState.IsValid) { db.Entry(firm).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(firm)); }
public void Update_OK() { /// changed values for tests Func <Entities> contextCreator = () => new Entities(); Firm updateEntity = new Firm { FirmId = "e20badcf-fd71-4ca1-9f2d-a8d1335f7c34", Description = "AN UPDATED FIRM", Name = "New FIRM", NumberOfEmployees = 10, Deleted = false, }; int result = instance.UpdateEntity(updateEntity); int expected = 1; Assert.AreEqual(expected, result); }
public void TestFindFirmConnectionByName2() { Firm firm = new Firm(); firm.NIP = "Firma"; List <Firm> list = new List <Firm>(); FirmLocalDataBase fldb = new FirmLocalDataBase(); fldb.Add(firm); string found = ""; for (int i = 0; i < list.Count; i++) { if (list[i].NIP == firm.NIP) { found = list[i].ReturnConnectionInfo(); } } string result = fldb.FindFirmConnectionByNIP(firm.NIP); Assert.AreNotEqual(found, result); }
static void Main(string[] args) { Person [] persons = new Person[3]; persons[0] = new Person() { name = "Ivanov", salary = 10000 }; persons[1] = new Person() { name = "Petrov", salary = 8000 }; persons[2] = new Person() { name = "Ivanov 2", salary = 15000 }; Firm firm = new Firm(persons); foreach (var item in firm) { Console.WriteLine(item); } }
private List <Fax> getMatchedFaxesRL(List <Firm> FirmList, String Source) { String sourceCopy = Source; List <Fax> resultFaxList = new List <Fax>(); List <string> Faxes = FaxList; int firmCount = FirmList.Count; for (int i = firmCount - 1; i >= 0; i--) { Firm firm = FirmList[i]; if (!String.IsNullOrEmpty(firm.firmName)) { foreach (var faxNo in Faxes) { String pattern = firm.firmName + "(.*?)" + faxNo; Regex regex = new Regex(pattern); Match match = regex.Match(sourceCopy); if (match.Success) { if (match.Value.Length > 30) { if (match.Length < 180) { Fax fax = new Fax(); fax.matchedFaxNo = faxNo; fax.matchedFirmName = firm.firmName; fax.matchedLength = match.Length; resultFaxList.Add(fax); sourceCopy = sourceCopy.Replace(match.Value, ""); } } } } } } return(resultFaxList); }
public ActionResult Edit(int id, Firm firm, int? decissionId = null) { ViewBag.DecissionId = decissionId; firm.Review = false; if (ModelState.IsValid) { _firmRepository.EnsurePersistent(firm); Message = string.Format(Messages.Saved, "Firm"); if(decissionId != null) { return this.RedirectToAction<SeminarApplicationController>(a => a.Decide(decissionId.Value)); } return this.RedirectToAction(a => a.Index()); } // if review, get the last one, if it exists var origFirm = firm.Review ? (_firmService.GetFirm(firm.FirmCode)) : firm; var viewModel = FirmViewModel.Create(Repository, firm, origFirm); return View(viewModel); }
// NLogProject.LogMaker Logger = new NLogProject.LogMaker(); public MainWindowViewModel() { Logger = new LogMaker(); FP = new FileProcessing(); SelectedFirm = "Не выбрано"; SelectedType = "Не выбрано"; this.Firm = new List <string>(); Firm.Add("Не выбрано"); Firm.Add("Ilford"); Firm.Add("Kodak"); Firm.Add("Fujifilm"); Firm.Add("Foma"); this.ISO = new List <int>(); ISO.Add(0); ISO.Add(50); ISO.Add(100); ISO.Add(200); ISO.Add(400); ISO.Add(800); this.Type = new List <string>(); Type.Add("Не выбрано"); Type.Add("Ч/б"); Type.Add("Цветная"); AllFilms = FP.FilmsFromDB; FilmsToView = AllFilms; stringsToView = MakeStrings(AllFilms); Temperature = FP.Temperature; CityName = FP.City; Logger.LogInfo("Программа запущена"); }
/// <summary> /// Global değişken MappingMailSource içerisinde arama yapar,eşleşyirsa gelen firm nesnesine mail ekler ve return eder /// Ayrıca eşleşme durumunda MappingMailSource içerisinden eşlenen değeri siler(performans nedeniyle) /// Ve son olarak MailList içerisinde eşleşen maili siler. /// </summary> /// <param name="firm"></param> /// <param name="Mails"></param> /// <returns></returns> public Firm mappingMailAddress(Firm firm) { String firmName = firm.firmName; Regex regex; String pattern; Match match; List <string> Mails = MailList; if (firmName.Length > 0) { foreach (var mail in Mails) { pattern = firmName + "(.*?)" + mail; regex = new Regex(pattern); match = regex.Match(MappingMailSource); // mail source içerisinde eşleştirme aranıyor if (match.Success) // eşleşme varsa { if (match.Length > 30) // eşleşen değerin uzunluğu en az 31 olmalı { if (match.Length < 300) // en çok 149 olmalı { firm.firmMail = mail; // gelen firm nesnesinin mail alanı set edilip geri döndürülecek MappingMailSource = MappingMailSource.Replace(match.Value, ""); MailList.Remove(mail); } else // Eşleşme uzunluğu 150den büyükse doğru eşleşme sağlanmamıştır. { MappingMailSource = MappingMailSource.Replace(match.Value, ""); MailList.Remove(mail); } } break; // eşleşirse döngüden çık } } } return(firm); }
public Employee GetById(int id) { conn = new SqlConnection(connectionString); conn.Open(); string selectById = "SELECT * FROM Employee WHERE id = @id"; SqlCommand cmd = new SqlCommand(selectById, conn); cmd.Parameters.AddWithValue("@id", id); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataSet ds = new DataSet(); DataTable dt = new DataTable(); adapter.Fill(ds, "Employee"); dt = ds.Tables["Employee"]; conn.Close(); Employee retVal = null; foreach (DataRow row in dt.Rows) { int emp_id = int.Parse(row["id"].ToString()); string name = row["name"].ToString(); string lastname = row["lastname"].ToString(); Firm firm = firmRepo.GetById(int.Parse(row["firm_id"].ToString())); retVal = new Employee() { Id = emp_id, Name = name, LastName = lastname, Firm = firm }; } return(retVal); }
public async Task <IActionResult> Create(CreateFirmViewModel model) { if (ModelState.IsValid) { Firm firm = new Firm { FirmName = model.FirmName, FirmAddress = model.FirmAddress, }; _context.Add(firm); await _context.SaveChangesAsync(); Wallet wallet = new Wallet { Balance = 0, Currency = model.Currency, FirmID = firm.FirmID, WalletName = firm.FirmName + " " + model.Currency }; _context.Add(wallet); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Curryncies = new SelectList(curryncies); return(View(model)); }
public async Task <IActionResult> Edit(Firm firm) { if (ModelState.IsValid) { try { await _repository.UpdateAsync(firm); } catch (DbUpdateConcurrencyException) { if (!FirmExists(firm.FirmId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(firm)); }
public async Task <InvokedResult <string> > CreateFirmAsync(Firm firm) { var responseBody = await m_TbdClient.PostAsync($"{m_OpenApiUrl}Firms", new { name = firm.Name, shortName = string.IsNullOrEmpty(firm.ShortName) ? firm.Name : firm.ShortName, sourceChannel = m_SourceChannel, sourceId = firm.Id, location = firm.Location, industry = firm.Industry, identityType = 1, status = firm.Status }); var result = JsonConvert.DeserializeObject <WebApiResponse <string> >(responseBody); if (!result.Success) { throw new Exception($"创建公司出错:{result.Error.Description}"); } return(InvokedResult.Ok(result.Data)); }
public List<Firm> GetAllFirm() { var table = data.getAllFirm(); List<Firm> firms = new List<Firm>(); foreach (var col in table) { Firm firm = new Firm(); firm.FirmAddress = col.firm_address; firm.FirmID = col.firm_id; firm.FirmName = col.firm_name; firm.PhoneNumber = col.phone_number; firms.Add(firm); } return firms; }
private void SaveFirm() { var factory = SessionConfig.SessionFactory; Address _address = UserContolToValueObject.ReturnAddress(addressUserControlFirm); PhoneNumber _phone = UserContolToValueObject.ReturnPhoneNumber(phoneUserControlFirm); using (var session = factory.OpenSession()) { using (var transaction = session.BeginTransaction()) { var newFirm = new Firm() { FirmName = firmNameTextBox.Text, PhoneNumber = _phone, Address = _address, FirmDescription = firmDescriptionRichTextBox.Text, }; session.Save(newFirm); transaction.Commit(); } } }
public ActionResult AddConfirm(int id, int personId, SeminarPerson seminarPerson, Firm firm) { var seminar = _seminarRespository.GetNullableById(id); if (seminar == null) { Message = string.Format(Messages.NotFound, "Seminar", id); return this.RedirectToAction<SeminarController>(a => a.Index()); } var person = _personRepository.GetNullableById(personId); if (person == null) { Message = string.Format(Messages.NotFound, "person", personId); return this.RedirectToAction(a => a.Add(id)); } if (firm.Id > 0) { seminarPerson.Firm = _firmRepository.GetNullableById(firm.Id); } else if (firm.Id == 0) { seminarPerson.Firm = firm; } // fill in the values seminarPerson.Person = person; seminarPerson.Seminar = seminar; ModelState.Clear(); seminarPerson.TransferValidationMessagesTo(ModelState); if (seminarPerson.Firm != null) { seminarPerson.Firm.TransferValidationMessagesTo(ModelState); } if (ModelState.IsValid) { _seminarPersonRepository.EnsurePersistent(seminarPerson); Message = string.Format("{0} has been added to the {1} seminar.", person.FullName, seminar.Year); _notificationService.AddToMailingList(seminar, person, MailingLists.Registered); // add user to the reminder emails _notificationService.AddToMailingList(seminar, person, MailingLists.PaymentReminder); _notificationService.AddToMailingList(seminar, person, MailingLists.HotelReminder); if (string.IsNullOrWhiteSpace(person.Biography)) _notificationService.AddToMailingList(seminar, person, MailingLists.BioReminder); if (person.OriginalPicture == null) _notificationService.AddToMailingList(seminar, person, MailingLists.PhotoReminder); return this.RedirectToAction(a => a.Add(id)); } var viewModel = AddConfirmViewModel.Create(Repository, _firmService, seminar, person, seminarPerson, seminarPerson.Firm); return View(viewModel); }
private static void ReadData(string file, bool imported, List<Firm> firms, List<KeyValuePair<string, string>> errors) { var sheet = ExcelHelpers.OpenWorkbook(HostingEnvironment.MapPath(file)); for (var i = sheet.FirstRowNum + 1; i <= sheet.LastRowNum; i++) { var row = sheet.GetRow(i); try { var f_id = ExcelHelpers.ReadIntCell(row, 13); // check the existance if (Db.Firms.Any(a => a.f_id == f_id)) throw new Exception("Already exists"); // check and see if we came across it already in this file var item = firms.Where(a => a.f_id == f_id).FirstOrDefault(); if (item != null) { errors.Add(new KeyValuePair<string, string>(f_id.ToString(), "duplicate value, replacing old")); // get the index to remove the first one firms.Remove(item); } var firm = new Firm(); firm.City = ExcelHelpers.ReadCell(row, 0); // a firm.Country = ExcelHelpers.ReadCell(row, 1); // b firm.State = ExcelHelpers.ReadCell(row, 2); // c firm.Address = ExcelHelpers.ReadCell(row, 3); // d firm.Zip = ExcelHelpers.ReadCell(row, 4); // e firm.IsPOBox = ExcelHelpers.ReadBoolCell(row, 5); // f firm.Fax = ExcelHelpers.ReadCell(row, 6); // g firm.Phone = ExcelHelpers.ReadCell(row, 7); // h firm.Ext = ExcelHelpers.ReadCell(row, 8); // i firm.Created = ExcelHelpers.ReadDateCell(row, 9); // j firm.Modified = ExcelHelpers.ReadDateCell(row, 10); // k firm.Description = ExcelHelpers.ReadCell(row, 11); // l firm.Financial = ExcelHelpers.ReadBoolCell(row, 12); // m firm.f_id = ExcelHelpers.ReadIntCell(row, 13); // n firm.Name = ExcelHelpers.ReadCell(row, 14); // o firm.CreatedBy = ExcelHelpers.ReadCell(row, 15); // p firm.ModifiedBy = ExcelHelpers.ReadCell(row, 16); // q firm.WebAddress = ExcelHelpers.ReadCell(row, 17); // r // check the name against one that has already been created var db = Db.Firms.Where(a => a.Name.Trim().ToLower() == firm.Name.Trim().ToLower()).FirstOrDefault(); var list = firms.Where(a => a.Name.Trim().ToLower() == firm.Name.Trim().ToLower()).FirstOrDefault(); if (db != null) { firm.GroupId = db.GroupId; } else if (list != null) { firm.GroupId = list.GroupId; } else { firm.GroupId = Guid.NewGuid(); } firms.Add(firm); } catch (Exception ex) { errors.Add(new KeyValuePair<string, string>(ExcelHelpers.ReadIntCell(row, 13).ToString(), ex.Message)); } } if (!imported) { foreach (var a in firms) { Db.Firms.Add(a); } Db.SaveChanges(); } }
public static PersonViewModel Create(IRepository repository, IFirmService firmService, string site, Seminar seminar = null, Person person = null, string email = null, Firm firm = null) { Check.Require(repository != null, "Repository must be supplied"); var viewModel = new PersonViewModel() { Person = person ?? new Person(), Addresses = repository.OfType<AddressType>().Queryable.Select(a => new Address() { AddressType = a}).ToList(), Contacts = repository.OfType<ContactType>().Queryable.Select( a => new Contact(){ContactType = a}).ToList(), Countries = repository.OfType<Country>().GetAll(), CommunicationOptions = repository.OfType<CommunicationOption>().GetAll(), SeminarPerson = person != null ? person.GetLatestRegistration(site) : null, Email = email, Seminar = seminar, Commodities = repository.OfType<Commodity>().Queryable.Where(a=>a.IsActive).ToList(), Firm = firm ?? new Firm() }; if (firm == null && viewModel.SeminarPerson != null) { viewModel.Firm = viewModel.SeminarPerson.Firm; } // find any addresses and replace them into the list if (person != null) { foreach(var a in person.Addresses) { var addr = viewModel.Addresses.Where(b => b.AddressType == a.AddressType).FirstOrDefault(); if (addr != null) viewModel.Addresses.Remove(addr); viewModel.Addresses.Add(a); } foreach (var a in person.Contacts) { var ct = viewModel.Contacts.Where(b => b.ContactType == a.ContactType).FirstOrDefault(); if (ct != null) viewModel.Contacts.Remove(ct); viewModel.Contacts.Add(a); } } // reorder so always in the same order viewModel.Addresses = viewModel.Addresses.OrderBy(a => a.AddressType.Id).ToList(); viewModel.Contacts = viewModel.Contacts.OrderBy(a => a.ContactType.Id).ToList(); // get the firms and add the "Other" option var firms = new List<Firm>(firmService.GetAllFirms()); firms.Add(new Firm() { Name = "Other (Not Listed)" }); viewModel.Firms = firms; if (viewModel.Person.User != null) viewModel.UserName = viewModel.Person.User.UserName; return viewModel; }
public LogisticsServiceContract(BusinessEstablishment producer, Firm consumer) : base(producer) { Consumer = consumer; }