public IActionResult Put(Raspored r) { try { var rasporedDB = db.Raspored .Include(x => x.StudentNavigation) .Include(x => x.LabVezbaNavigation) .ThenInclude(x => x.IdLabVezbeNavigation) .FirstOrDefault(x => x.Id == r.Id); rasporedDB.Ucionica = r.Ucionica; rasporedDB.PocetakLaba = Convert.ToDateTime(r.PocetakLaba); rasporedDB.ZavrsetakLaba = Convert.ToDateTime(r.ZavrsetakLaba); rasporedDB.Izmenjen = true; notifier.Send(rasporedDB.StudentNavigation.Username, $"Obaveštenje o lab vežbama. Došlo je do izmene za {rasporedDB.LabVezbaNavigation.IdLabVezbeNavigation.Naziv} - {rasporedDB.LabVezbaNavigation.Redosled} termin {rasporedDB.PocetakLaba}"); db.SaveChanges(); return(Ok()); } catch (Exception) { return(BadRequest()); } }
static void Main(string[] args) { Console.WriteLine("Creating stock dictionary"); Dictionary <string, Stock> stocks = new Dictionary <string, Stock>(); Console.WriteLine("Checking to see if there is already an data analysis for today"); if (File.Exists("stocksWithIndicators.bin") && new FileInfo("stocksWithIndicators.bin").CreationTime.Date == DateTime.Now.Date) { Console.WriteLine("There is. Recovering file"); StockState ss = new StockState(); stocks = ss.Deserialize("stocksWithIndicators.bin"); } else { Console.WriteLine("There is not. Procceding with Analysis."); Console.WriteLine("Getting most recent stock market file"); HistoryFileSelector hfs = new HistoryFileSelector(@"C:\Users\Cliente\Downloads"); string mostRecent = hfs.GetMostRecentFileFullPath(); Console.WriteLine("Reading data from file"); stocks = Reader.GetAllStockData(mostRecent); Console.WriteLine("Analyzing data"); sw.Start(); MarketHistoryAnalyzer.FillAllWithDefaults(stocks, PrintProgress); sw.Stop(); Console.WriteLine("Saving to disk"); StockState sc1 = new StockState(stocks); sc1.Serialize("stocksWithIndicators.bin"); } Console.WriteLine("Removing stocks not traded every day"); List <Stock> tradedEveryday = StockComparer.RemoveStocksNotTradedEveryday(stocks); Console.WriteLine("Creating Stock Comparator"); StockComparer sc = new StockComparer(tradedEveryday); Console.WriteLine("Running comparison"); //List<Stock> rankedStocks = StockComparer.RankOfBestStocks(tradedEveryday); sc.RankStocksByCompare(); Console.WriteLine("Saving to disk"); StockState sc2 = new StockState(sc.RankedStocks); sc2.Serialize("rankedStocks.bin"); Console.WriteLine("Emailing results"); EmailNotifier en = new EmailNotifier("ff12sender", "33914047"); en.Send(sc.RankedStocks); Console.WriteLine("All done. Check your email"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
public void SaveObjective(ObjectiveSub sub) { EmailNotifier notifier = new EmailNotifier(); InsertObjectiveSub(sub); GetUnitOfWork().Save(); string email = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email; string sender = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName; if (String.IsNullOrEmpty(email)) { notifier.Send("/#/othersObjectives?id=" + CreatedBy, "Dear sir,<br/> I have submited my job objective on " + DateTime.Now.Date + ".", email, sender); } }
public void ApproveObjectiveByReportee(string id) { var desc = GetUnitOfWork().ObjectiveSubRepository.Get().FirstOrDefault(a => a.Id == id); if (desc != null) { EmailNotifier notifier = new EmailNotifier(); desc.IsObjectiveApproved = true; GetUnitOfWork().Save(); string email = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email; string sender = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName; notifier.Send("", "Dear employee,\n I have reviewed your job objective on " + DateTime.Now.Date + ".", email, sender); } else { throw new Exception("This employee has not set his/her job description yet!"); } }
public void Save(JobDescription description) { UnitOfWork unitOfWork = new UnitOfWork(); if (description.Id != Guid.Empty) { JobDescription descriptions = unitOfWork.JobDescriptionRepository.GetById(description.Id); if (descriptions == null) { throw new Exception("We can't find your job description "); } descriptions.KeyAccountabilities = description.KeyAccountabilities; descriptions.JobPurposes = description.JobPurposes; descriptions.UpdatedBy = CreatedBy; descriptions.UpdatedDate = DateTime.Now; unitOfWork.JobDescriptionRepository.Update(descriptions); } else { Validation validation = new Validation(new UnitOfWork()); if (validation.HasSetJobDescription(CreatedBy)) { throw new Exception("You already set a job description."); } description.CreatedBy = CreatedBy; description.EmployeeId = CreatedBy; description.IsReportToConfirmed = false; description.IsHOBUConfirmed = false; description.CreatedDate = DateTime.Now; description.Id = Guid.NewGuid(); unitOfWork.JobDescriptionRepository.Insert(description); } unitOfWork.Save(); EmailNotifier notifier = new EmailNotifier(); string email = unitOfWork.EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email; string sender = unitOfWork.EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName; if (String.IsNullOrEmpty(email)) { notifier.Send("/#/MyEmployee?id=" + CreatedBy, "Dear sir,<br/> I have submited my job description on " + DateTime.Now.Date + ".", email, sender); } }
public bool RunAnalysis() { //UpdateLabel ul = new UpdateLabel(updateInfoLabel); updateInfoLabel("Creating stock dictionary"); Dictionary <string, Stock> stocks = new Dictionary <string, Stock>(); //string filePath = fileLocationTxtBox.Text; updateInfoLabel("Reading data from file"); stocks = Reader.GetAllStockData(fileLocation); updateInfoLabel("Analyzing data"); MarketHistoryAnalyzer.FillAllWithDefaults(stocks, SetProgress); updateInfoLabel("Saving to disk"); StockState sc1 = new StockState(stocks); sc1.Serialize("stocksWithIndicators.bin"); updateInfoLabel("Removing stocks not traded every day"); List <Stock> tradedEveryday = StockComparer.RemoveStocksNotTradedEveryday(stocks); updateInfoLabel("Creating Stock Comparator"); StockComparer sc = new StockComparer(tradedEveryday); updateInfoLabel("Running comparison"); sc.RankStocksByCompare(); updateInfoLabel("Saving to disk"); StockState sc2 = new StockState(sc.RankedStocks); sc2.Serialize("rankedStocks.bin"); updateInfoLabel("Emailing results"); EmailNotifier en = new EmailNotifier("ff12sender", "33914047"); en.Send(sc.RankedStocks); updateInfoLabel("All done. Check your email"); return(true); }
public void TestEmailNotifier() { //the contents of the email StockState ss = new StockState(); Dictionary <string, Stock> rankDic = ss.Deserialize("rankedStocks.bin"); EmailNotifier en = new EmailNotifier("*****@*****.**", "33914047"); StringBuilder sb = new StringBuilder(); int i = 1; foreach (KeyValuePair <string, Stock> s in rankDic) { sb.Append(i + ". " + s.Value.stockCode + "\n"); i++; } en.Send("StockMarket Rank", sb.ToString()); }
public void ApproveJobDescriptionByReportee(string employeeId) { var desc = GetUnitOfWork().JobDescriptionRepository.Get().FirstOrDefault(a => a.EmployeeId == employeeId); if (desc != null) { EmailNotifier notifier = new EmailNotifier(); desc.IsReportToConfirmed = true; desc.IsHOBUConfirmed = true; desc.HOBUConfirmedDate = DateTime.Now; GetUnitOfWork().Save(); string email = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.Employee2?.Email; string sender = GetUnitOfWork().EmployeeRepository.Get().FirstOrDefault(a => a.EmployeeId == CreatedBy)?.EmployeeName; if (email != null) { notifier.Send("", "Dear employee,\n I have reviewed your job description on " + DateTime.Now.Date + ".", email, sender); } } else { throw new Exception("This employee has not set his/her job description yet!"); } }