Example #1
0
 public bool saveContactPerson(ref NewsEvent newsEvent, ref string returnMessage, int userId)
 {
     result = false;
     using (KarachiNPcontext)
     {
         if (newsEvent != null && newsEvent.NewsEventId > 0)//Edit
         {
             int       newsEventId  = newsEvent.NewsEventId;
             NewsEvent objnewsEvent = KarachiNPcontext.NewsEvents.Where(a => a.NewsEventId == newsEventId).FirstOrDefault();
             objnewsEvent.IsActive          = true;
             objnewsEvent.NewsEventDate     = newsEvent.NewsEventDate;
             objnewsEvent.NewsEventDetail   = newsEvent.NewsEventDetail;
             objnewsEvent.NewsEventTitle    = newsEvent.NewsEventTitle;
             objnewsEvent.ShowOnDashBoard   = newsEvent.ShowOnDashBoard;
             objnewsEvent.NewsEventCategory = newsEvent.NewsEventCategory;
             objnewsEvent.ModifiedBy        = userId;
             objnewsEvent.ModifiedDate      = DateTime.Now;
             result = true;
         }
         else
         {
             newsEvent.CreatedBy   = userId;
             newsEvent.CreatedDate = DateTime.Now;
             KarachiNPcontext.NewsEvents.Add(newsEvent);
             result = true;
         }
         KarachiNPcontext.SaveChanges();
         int id = newsEvent.NewsEventId;
         newsEvent = KarachiNPcontext.NewsEvents.Where(a => a.NewsEventId == id).FirstOrDefault();
         return(result);
     }
 }
        public ActionResult Edit(NewsEvent newsEvent, List <HttpPostedFileBase> Images)
        {
            if (ModelState.IsValid)
            {
                newsEvent.UpdatedAt       = DateTime.Now;
                newsEvent.UpdatedBy       = User.Identity.Name;
                db.Entry(newsEvent).State = EntityState.Modified;
                db.SaveChanges();
                if (!Directory.Exists(Path.Combine(Server.MapPath("~/Admin/Images/News/" + newsEvent.Id))))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Admin/Images/News/" + newsEvent.Id));
                }

                if (Images.Count > 0)
                {
                    foreach (HttpPostedFileBase fi in Images)
                    {
                        //Checking file is available to save.
                        if (fi != null)
                        {
                            var InputFileName = Path.GetFileName(fi.FileName);
                            int size          = fi.ContentLength / 1000000;

                            string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
                            Regex  r           = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
                            InputFileName = r.Replace(InputFileName, "");

                            string extension = Path.GetExtension(fi.FileName);
                            if (ImageExt.Contains(extension.ToUpper()))
                            {
                                string path           = Server.MapPath("~/Admin/Images/News/") + newsEvent.Id + "/" + InputFileName;
                                var    ServerSavePath = Path.Combine(path);
                                //Save file to server folder
                                fi.SaveAs(ServerSavePath);
                                if (System.IO.File.Exists(path))
                                {
                                    ImageFile file = new ImageFile
                                    {
                                        Name         = InputFileName,
                                        Size         = size,
                                        path         = "~/Admin/Images/News/" + newsEvent.Id + "/" + InputFileName,
                                        Type         = "Image",
                                        UploadedBy   = "Admin",
                                        UploadedDate = DateTime.Now
                                    };
                                    db.ImageFile.Add(file);
                                    db.SaveChanges();

                                    ImageFile image = db.ImageFile.OrderByDescending(m => m.Id).FirstOrDefault();
                                    newsEvent.Files.Add(image);
                                    db.SaveChanges();
                                }
                            }
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(newsEvent));
        }
        // GET: NewsEvents/Create
        public ActionResult Create()
        {
            NewsEvent news = new NewsEvent();

            news.UploadDate = DateTime.Now;
            return(View(news));
        }
Example #4
0
 public ActionResult AddEdit(int?id, NewsEvent model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool isNew = false;
             //FeedFooder feed = isNew ? new FeedFooder { } : _repo.GetById(id.Value);
             // feed = model;
             if (!id.HasValue)
             {
                 model.UpdatedBy = "admin";
                 isNew           = true;
             }
             if (isNew)
             {
                 model.Id        = 0;
                 model.UpdatedAt = DateTime.Now;
                 _repo.NewsEvents.Insert(model);
                 _repo.Save();
             }
             else
             {
                 _repo.NewsEvents.Update(model);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
Example #5
0
        public async Task <IActionResult> Delete(int id)
        {
            NewsEvent news = await _repo.NewsEvents.GetById(id);

            _repo.NewsEvents.Delete(id);

            return(RedirectToAction("Index"));
        }
Example #6
0
    public void addNewsEvent(FindObjects findObjects, NewsEffect newsEffect)
    {
        NewsEvent newsEvent = new NewsEvent();

        newsEvent.findObjects = findObjects;
        newsEvent.newsEffect  = newsEffect;
        newsEvents.Add(newsEvent);
    }
Example #7
0
 private void ObjectToForm(NewsEvent newsEvent)
 {
     ddlCategory.SelectedValue         = newsEvent.NewsEventCategory;
     txtNewsEventDate.Text             = newsEvent.NewsEventDate.ToString();
     txtDetail.Text                    = newsEvent.NewsEventDetail;
     txtTitle.Text                     = newsEvent.NewsEventTitle;
     rblst_showonDesktop.SelectedValue = newsEvent.ShowOnDashBoard.ToString();
     lblNewsEventId.Text               = newsEvent.NewsEventId.ToString();
 }
Example #8
0
    public static void CreateNewsEvent()
    {
        NewsEvent asset = (NewsEvent)CreateAsset("DoVAlpha/GovernmentsDefault/data/events/", typeof(NewsEvent));

        if (asset != null)
        {
            asset.EventName = "some government";
        }
    }
Example #9
0
        //Event Mangement

        #region NewsEvents Section


        public NewsEvent Addnewsevent(NewsEvent eventinfo)
        {
            try
            {
                _entity.NewsEvents.Add(eventinfo);
                _entity.SaveChanges();
                return(eventinfo);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        // GET: NewsEvents/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewsEvent newsEvent = db.NewsEvents.Find(id);

            if (newsEvent == null)
            {
                return(HttpNotFound());
            }
            return(View(newsEvent));
        }
Example #11
0
        public bool Updatenewsevent(NewsEventsModel newsEvents)
        {
            var objnewsevents = new NewsEvent
            {
                CreateDate   = DateTime.Now,
                Description  = newsEvents.Description,
                HeadLine     = newsEvents.HeadLine,
                IsActive     = true,
                ModifiedDate = DateTime.Now,
                Id           = newsEvents.Id,
                PlaceofEvent = newsEvents.PlaceofEvent,
                EventDate    = newsEvents.EventDate,
            };

            return(_objRepository.Updatenewsevent(objnewsevents));
        }
Example #12
0
 public bool deleteNewsEvent(int newsEventId, ref string returnMessage, int userId)
 {
     using (KarachiNPcontext)
     {
         NewsEvent newsEvent = KarachiNPcontext.NewsEvents.Where(a => a.NewsEventId == newsEventId).FirstOrDefault();
         if (newsEvent != null)
         {
             newsEvent.IsActive     = false;
             newsEvent.ModifiedBy   = userId;
             newsEvent.ModifiedDate = DateTime.Now;
             KarachiNPcontext.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Example #13
0
        public async Task <IActionResult> AddEdit(int?id)
        {
            NewsEvent news = new NewsEvent();

            // ViewBag.Species = new SelectList(_repo.Species.GetModel(), "id", "speciesName");
            if (id.HasValue)
            {
                NewsEvent newsEvent = await _repo.NewsEvents.GetById(id.Value);


                if (newsEvent != null)
                {
                    news = newsEvent;
                }
            }
            return(View(news));
        }
Example #14
0
        public ActionResult Create(NewsEvent model)
        {
            try
            {
                UploadFile(HttpContext.Request, model);

                _newsEventService.Add(model);
                _newsEventService.Save();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "File upload failed!!";
                return(View());
            }
        }
Example #15
0
 static NewsCasterModel()
 {
     if (_useDb)
     {
         SavedNews = ForexStorage.UseForexContext(c => c.Event__News.ToArray()
                                                  .Select(ne => new NewsEvent()
         {
             Country = ne.Country,
             Level   = (NewsEventLevel)Enum.Parse(typeof(NewsEventLevel), ne.Level),
             Name    = ne.Name,
             Time    = ne.Time
         }).ToArray(),
                                                  (c, e) => {
             Default.Log = e;
             SavedNews   = new NewsEvent[0];
         });
     }
 }
Example #16
0
        public DataTable NewsEventFollow(int Id, int cId)
        {
            DataTable dataTable = new DataTable();

            NewsEvent newsEvent = GetNewsEventById(Id);
            DateTime  PostTime  = newsEvent.PostDate;

            DataTable table = GetNewsEventAll(Language.language);

            if (table != null)
            {
                DataView dataView = new DataView(table);
                dataView.RowFilter = "NewsEventID <> " + Id + "and CateNewsID = " + cId;
                dataView.Sort      = "PostDate DESC ";
                dataTable          = dataView.ToTable();
            }
            return(dataTable);
        }
Example #17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            NewsEvent newsEvent = formToObject();
            bool      result    = new EFNewsEvent().saveContactPerson(ref newsEvent, ref ErrorMessage, SessionHelper.getUserSession().userid);

            if (result)
            {
                lblMessage.Text = "";
                FormReset();
                FormLoad();
                MisOp.ShowMessage(this, "The Record has been saved", "News Event ", true);
                //return;
            }
            else
            {
                lblMessage.Text = ErrorMessage;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            IEnumerable <ImageFile> files = db.NewsEvents.Include(mbox => mbox.Files).FirstOrDefault(m => m.Id == id).Files;

            foreach (var item in files)
            {
                if (System.IO.File.Exists(Server.MapPath(item.path)))
                {
                    System.IO.File.Delete(Server.MapPath(item.path));
                }
                db.ImageFile.Remove(item);
                db.SaveChanges();
            }
            NewsEvent newsEvent = db.NewsEvents.Find(id);

            db.NewsEvents.Remove(newsEvent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #19
0
        public bool Deletenewsevents(int id)
        {
            try
            {
                NewsEvent newsevent = _entity.NewsEvents.First(m => m.Id == id);

                var geteventImages = _entity.Galleries.Where(a => a.EventId == id).ToList();
                if (geteventImages != null && geteventImages.Any())
                {
                    _entity.Galleries.RemoveRange(geteventImages);
                }
                _entity.NewsEvents.Remove(newsevent);
                _entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #20
0
        public ActionResult EditPost(Guid id, NewsEvent model)
        {
            try
            {
                var photoModel = _newsEventService.GetAll().Where(x => x.Id == id).SingleOrDefault();
                photoModel.Title           = model.Title;
                photoModel.DateOfNews      = model.DateOfNews;
                photoModel.FullDescription = model.FullDescription;
                photoModel.IsActive        = model.IsActive;

                _newsEventService.Edit(photoModel);
                _newsEventService.Save();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Example #21
0
        public NewsEvent formToObject()
        {
            NewsEvent newsEvent = new NewsEvent();

            newsEvent.IsActive = true;
            if (txtNewsEventDate.Text != "")
            {
                newsEvent.NewsEventDate = Convert.ToDateTime(txtNewsEventDate.Text);
            }
            newsEvent.NewsEventDetail = txtDetail.Text;
            if (lblNewsEventId.Text != "")
            {
                newsEvent.NewsEventId = Convert.ToInt32(lblNewsEventId.Text);
            }
            newsEvent.ShowOnDashBoard   = rblst_showonDesktop.SelectedValue.ToUpper() == "YES" ? true : false;
            newsEvent.NewsEventTitle    = txtTitle.Text;
            newsEvent.NewsEventCategory = ddlCategory.SelectedValue.ToString();


            return(newsEvent);
        }
Example #22
0
 protected void rptrNewsEvent_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.ToUpper() == "NEWSEVENTDELETE")
     {
         if (deleteNewsEvent(Convert.ToInt32(e.CommandArgument.ToString())))
         {
             FormReset();
             FormLoad();
         }
     }
     else if (e.CommandName == "NEWSEVENTEDIT")
     {
         newsEvent = getNewsEventByNewsEventId(Convert.ToInt32(e.CommandArgument.ToString()));
         if (newsEvent != null)
         {
             ObjectToForm(newsEvent);
             // btnCancel.Visible = true;
             //btnBack.Visible = false;
         }
     }
 }
Example #23
0
        private void UploadFile(HttpRequestBase request, NewsEvent model)
        {
            if (request.Files.AllKeys.Any())
            {
                // Get the uploaded image from the Files collection
                var httpPostedFile = request.Files[0];

                var fileName = httpPostedFile.FileName;

                if (httpPostedFile != null)
                {
                    // Validate the uploaded image(optional)

                    // Get the complete file path
                    var fileSavePath = (HttpContext.Server.MapPath("~/NewsEventPhotos/") + model.Id + fileName.Substring(fileName.LastIndexOf('.')));

                    // Save the uploaded file to "UploadedFiles" folder
                    httpPostedFile.SaveAs(fileSavePath);
                    model.ImageUrl = fileSavePath;
                }
            }
        }
Example #24
0
        public bool Updatenewsevent(NewsEvent eventinfo)
        {
            try
            {
                var objnewsevent = _entity.NewsEvents.Single(d => d.Id == eventinfo.Id);

                objnewsevent.CreateDate   = DateTime.Now;
                objnewsevent.Description  = eventinfo.Description;
                objnewsevent.HeadLine     = eventinfo.HeadLine;
                objnewsevent.IsActive     = true;
                objnewsevent.EventDate    = eventinfo.EventDate;
                objnewsevent.PlaceofEvent = eventinfo.PlaceofEvent;
                objnewsevent.ModifiedDate = DateTime.Now;
                if (eventinfo.Galleries.Where(a => a.EventId != null).Any())
                {
                    objnewsevent.Galleries = eventinfo.Galleries;
                }
                else
                {
                    var images = _entity.Galleries.Where(a => a.EventId == eventinfo.Id);
                    foreach (var result in images)
                    {
                        if (result.EventId == null)
                        {
                            result.EventId = eventinfo.Id;
                        }
                    }
                    objnewsevent.Galleries = images.ToList();
                }
                _entity.SaveChanges();
                return(true);
            }


            catch (Exception)
            {
                return(false);
            }
        }
Example #25
0
 public void Update(NewsEvent entity)
 {
     _repositoryBase.Update(entity);
 }
Example #26
0
 public void Delete(NewsEvent entity)
 {
     _repositoryBase.Delete(entity);
 }
Example #27
0
 public void Add(NewsEvent entity)
 {
     _repositoryBase.Add(entity);
 }
        public PriceSeries GetRandomTrades(out List <Trade> trades, out List <NewsEvent> news)
        {
            var priceSeries = new PriceSeries();

            trades = new List <Trade>();
            news   = new List <NewsEvent>();

            var startDate = new DateTime(2012, 01, 01);

            double randomWalk = 0.0;

            // Note: Change the value below to increase or decrease the point count and trade frequency
            const int  Count          = 1000;
            const uint TradeFrequency = 14;

            // Generate the X,Y data with sequential dates on the X-Axis and slightly positively biased random walk on the Y-Axis
            for (int i = 0; i < Count; i++)
            {
                randomWalk += (_random.NextDouble() - 0.498);
                priceSeries.Add(new PriceBar(startDate.AddMinutes(i * 10), randomWalk, randomWalk, randomWalk, randomWalk, 0));
            }

            // The random walk is a truly random series, so it may contain negative values. Here we find the minimum and offset it
            // so it is always positive.
            double yOffset = -priceSeries.CloseData.Min() + _random.NextDouble();

            for (int i = 0; i < Count; i++)
            {
                // Now update with the offset so it is never negative
                priceSeries[i].Close += yOffset;

                // Every N'th tick create a random trade
                if (i % TradeFrequency == 0)
                {
                    var trade = new Trade();

                    // randomize buy or sell
                    trade.BuySell = _random.NextDouble() > 0.48 ? BuySell.Buy : BuySell.Sell;

                    // Set dealprice and date
                    trade.DealPrice = priceSeries[i].Close;
                    trade.TradeDate = priceSeries[i].DateTime;

                    // Set instrument and quantity
                    trade.Instrument = Instrument.CrudeOil;
                    trade.Quantity   = _random.Next(100, 500);
                    trades.Add(trade);
                }

                // Every N'th tick create a random news event
                if (_random.Next(0, 99) > 95)
                {
                    var newsEvent = new NewsEvent();

                    newsEvent.EventDate = priceSeries[i].DateTime;
                    newsEvent.Headline  = "OPEC meeting minutes";
                    newsEvent.Body      = "The Organization of the Petroleum Exporting Countries voted today to increase production of Crude oil from its member states";

                    news.Add(newsEvent);
                }
            }

            return(priceSeries);
        }
Example #29
0
 public NewsContainer(NewsEvent newsEvent)
 {
     this.Event = newsEvent;
     this.Date  = newsEvent.Time.ToLocalTime().Date;
 }
Example #30
0
		public void NewsAddEvent(NewsEvent newEvent)
		{
			NewsEvents.Add(newEvent);
		}
Example #31
0
		public void NewsReplaceEvent(NewsEvent oldEvent, NewsEvent newEvent)
		{
			if (NewsEvents.IndexOf(oldEvent) >= 0)
				NewsEvents.Remove(oldEvent);
			NewsEvents.Add(newEvent);
		}
Example #32
0
        public async Task <IActionResult> Details(int id)
        {
            NewsEvent news = await _repo.NewsEvents.GetById(id);

            return(View(news));
        }