Example #1
0
        public IActionResult Anouncements(AnouncementsModel AnM, IFormFile Doc)
        {
            if (Doc != null)
            {
                var fileName = Path.Combine(he.WebRootPath + "/anounceDoc", Path.GetFileName(Doc.FileName));
                Doc.CopyTo(new FileStream(fileName, FileMode.Create));
                AnM.DocUrl = Path.GetFileName(Doc.FileName);

                _db.anouncementsModels.Add(AnM);
                _db.SaveChanges();
            }
            return(View("Anouncements"));
        }
        public IActionResult UpdateAnounc(AnouncementsModel anounc, IFormFile Doc)
        {
            if (Doc != null)
            {
                dynamic data1    = _db.anouncementsModels.Where(x => x.Id == anounc.Id).FirstOrDefault();
                var     fileName = Path.Combine(he.WebRootPath + "/anounceDoc", Path.GetFileName(Doc.FileName));
                Doc.CopyTo(new FileStream(fileName, FileMode.Create));
                data1.Title   = anounc.Title;
                anounc.DocUrl = Path.GetFileName(Doc.FileName);
                data1.DocUrl  = anounc.DocUrl;
                // anounc.Date = DateTime.Now.Day.ToString () + "/" + DateTime.Now.Month.ToString () + "/" + DateTime.Now.Year.ToString ();

                _db.SaveChanges();
            }
            return(View("Index"));
        }