Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,shortURL,longUrl")] URLMapper uRLMapper)
        {
            if (ModelState.IsValid)
            {
                uRLMapper.shortURL = RandomString(7);
                db.URLMappers.Add(uRLMapper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(uRLMapper));
        }
Ejemplo n.º 2
0
        public ActionResult Create(int?ID, [Bind(Include = "name,key,booking")] PNL pnl)
        {
            if (ModelState.IsValid)
            {
                pnl.FileListId = ID == null ? 0 : (int)ID;

                dbcontext.FileLists.First(p => p.Id == ID).PNLs.Add(pnl);
                dbcontext.SaveChanges();
                string fileName = dbcontext.FileLists.Where(p => p.Id == ID).First().FileName;
                using (StreamWriter sw = new StreamWriter(Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName), true))
                {
                    sw.WriteLine(Environment.NewLine + "1" + pnl.name + "-" + pnl.key + " .L/" + pnl.booking);
                }

                return(View("Index", dbcontext.FileLists.First(p => p.Id == ID).PNLs));
            }
            ModelState.AddModelError("error_msg", "Error.Please enter all values");
            return(View("Create"));
        }
Ejemplo n.º 3
0
        public void uploadData(string path, string fileName)
        {
            FileList filelist = new FileList();

            filelist.FileName = fileName;

            using (StreamReader sr = new StreamReader(Path.Combine(path, fileName)))
            {
                foreach (PNL pnl in Helpers.Helper.getString(sr.ReadToEnd()))
                {
                    filelist.PNLs.Add(pnl);
                }
                ///  filelist.PNLs=Helpers.Helper.getString(sr.ReadToEnd());
            }


            context.FileLists.Add(filelist);
            context.SaveChanges();
            //throw new NotImplementedException();
        }