예제 #1
0
        public TRAVEL GetById2(int input)
        {
            TRAVEL travels = context.Travels.Find(input);

            var temp = from t in context.Travels.ToList()
                       join u in context.Users.ToList()
                       on t.user_id equals u.user_id
                       where t.travel_id == input
                       select t;

            if (travels == null)
            {
                Console.Write("Id " + input + " Tidak Ada");
            }
            else
            {
                Console.WriteLine("-------------------------\n");
                Console.WriteLine("Nama User        : "******"Category         : " + travels.category_id);
                Console.WriteLine("-------------------------");
                Console.WriteLine("Id               : " + travels.travel_id);
                Console.WriteLine("Departure Date   : " + travels.departure_date);
                Console.WriteLine("Arrival Date     : " + travels.arrival_date);
                Console.WriteLine("Destination      : " + travels.destination);
                Console.WriteLine("Status           : " + travels.status);
                Console.WriteLine("Total            : " + travels.total);
                Console.WriteLine("-------------------------");
            }
            return(travels);
        }
예제 #2
0
 public ActionResult EditTravel(TRAVEL travel, HttpPostedFileBase fileUpload)
 {
     if (ModelState.IsValid)
     {
         try
         {
             TRAVEL model = db.TRAVELs.Single(x => x.ID_TRAVEL == travel.ID_TRAVEL);
             model.NAME_TRAVEL      = travel.NAME_TRAVEL; //ve them cac field con lai
             model.ID_TRAVEL        = travel.ID_TRAVEL;
             model.IMAGE_TRAVEL     = travel.IMAGE_TRAVEL;
             model.INTRODUCE_TRAVEL = travel.INTRODUCE_TRAVEL;
             model.QUALITY_TRAVEL   = travel.QUALITY_TRAVEL;
             model.TEL_TRAVEL       = travel.TEL_TRAVEL;
             model.DES_TRAVEL       = travel.DES_TRAVEL;
             model.ID_CITY          = travel.ID_CITY;
             //model = hotel;
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Error", new { msg = ex.Message }));
         }
     }
     return(RedirectToAction("Travel"));
 }
예제 #3
0
        private string reseatMainInfo(TRAVEL travel, string result)
        {
            List <string> images = new List <string>();

            images.AddRange(travel.mainIng);
            foreach (string img in travel.imgs)
            {
                string ig = DATA.RevImageDict[img];
                if (!images.Contains(ig))
                {
                    images.Add(ig);
                }
            }
            string res = "";

            foreach (string img in images)
            {
                string itimgs = imgtemplate1;
                //    string ig = DATA.RevImageDict[img];
                itimgs = itimgs.Replace("$image1", travel.Id + "/" + img);
                res    = res + itimgs;
            }

            result = result.Replace("$items1", res);
            result = result.Replace("$title", travel.name);
            result = result.Replace("$ldate", travel.ldate);
            result = result.Replace("$desc", travel.description);
            result = result.Replace("$price", travel.lcount);
            result = result.Replace("$praceS", travel.praceS);
            result = result.Replace("$praceL", travel.praceL);


            return(result);
        }
예제 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            TRAVEL tRAVEL = db.TRAVELs.Find(id);

            db.TRAVELs.Remove(tRAVEL);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
        public int Delete(int input)
        {
            TRAVEL tRAVEL = context.Travels.Find(input);

            context.Entry(tRAVEL).State = System.Data.Entity.EntityState.Deleted;
            context.SaveChanges();
            Console.Write("Travel Request dengan ID " + input + " Berhasil terhapus!");
            return(input);
        }
예제 #6
0
        public TRAVEL GetById(int input)
        {
            TRAVEL travels = context.Travels.Find(input);

            if (travels == null)
            {
                Console.Write("Id " + input + " Tidak Ada");
            }
            return(travels);
        }
예제 #7
0
        public ActionResult DeleteTravel(int id)
        {
            //Lay ra doi tuong san pham can xoa theo ma
            TRAVEL travel = db.TRAVELs.SingleOrDefault(n => n.ID_TRAVEL == id);

            if (travel == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(travel));
        }
예제 #8
0
        // POST api/values
        public HttpResponseMessage Post(TravelEditModel model)
        {
            if (HttpContext.Current.Request.Headers["Authorization"] == null)
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            else
            {
                try
                {
                    TRAVEL travelBdd = new TRAVEL();
                    travelBdd.ID_ARRIVALAGENCY   = model.ArrivalAgency.Id;
                    travelBdd.ID_DEPARTUREAGENCY = model.DepartureAgency.Id;
                    travelBdd.ARRIVALHOUR        = model.ArrivalTime;
                    travelBdd.DEPARTUREHOUR      = model.DepartureTime;
                    travelBdd.CAPACITY           = model.Capacity;

                    PUBLICATION publicationBdd = new PUBLICATION();

                    string      tokenString = HttpContext.Current.Request.Headers["Authorization"];
                    UserManager userManager = new UserManager();
                    publicationBdd.ID_USER            = userManager.getUserFromSession(new Guid(tokenString));
                    publicationBdd.TITLE              = model.Publication.Title;
                    publicationBdd.DESCRIPTION        = model.Publication.Description;
                    publicationBdd.ID_GROUP           = 1;
                    publicationBdd.ID_CATEGORY        = 1;
                    publicationBdd.DATE_TIME_CREATION = DateTime.Now.AddHours(1);


                    manager.add(travelBdd, publicationBdd);
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Success = true,     //error
                            Message = "Success" //return exception
                        })
                    });
                }
                catch (Exception e)
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Success = false,                                                                                                      //error
                            Message = "Exception with token :" + HttpContext.Current.Request.Headers["Authorization"] + " Error :" + e.ToString() //return exception
                        })
                    });
                }
            }
        }
예제 #9
0
 public ActionResult Edit([Bind(Include = "ID_TRAVEL,ID_DEPARTUREAGENCY,ID_ARRIVALAGENCY,CAPACITY,DEPARTUREHOUR,ARRIVALHOUR,ID_PUBLICATION")] TRAVEL tRAVEL)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tRAVEL).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_ARRIVALAGENCY   = new SelectList(db.AGENCies, "ID_AGENCY", "NAME", tRAVEL.ID_ARRIVALAGENCY);
     ViewBag.ID_DEPARTUREAGENCY = new SelectList(db.AGENCies, "ID_AGENCY", "NAME", tRAVEL.ID_DEPARTUREAGENCY);
     ViewBag.ID_PUBLICATION     = new SelectList(db.PUBLICATIONs, "ID_PUBLICATION", "TITLE", tRAVEL.ID_PUBLICATION);
     return(View(tRAVEL));
 }
예제 #10
0
        // GET: Travel/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRAVEL tRAVEL = db.TRAVELs.Find(id);

            if (tRAVEL == null)
            {
                return(HttpNotFound());
            }
            return(View(tRAVEL));
        }
예제 #11
0
        private void addLSText(string number, TRAVEL travel, string ffFullName)
        {
            string        l;
            string        s;
            List <string> ll      = new List <string>();
            List <string> ls      = new List <string>();
            string        stage   = "";
            string        content = FILEWORK.ReadFileContent(ffFullName);

            String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None);
            foreach (string line in lines)
            {
                if (String.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (line.ToUpper() == "LENA")
                {
                    stage = "lena";
                    continue;
                }

                if (line.ToUpper() == "SERGEY")
                {
                    stage = "sergey";
                    continue;
                }

                if (stage == "lena")
                {
                    ll.Add(line);
                }

                if (stage == "sergey")
                {
                    ls.Add(line);
                }
            }

            l = string.Join("\n", ll.ToArray());
            s = string.Join("\n", ls.ToArray());
            TRAVEL.LSTEXT tt = new TRAVEL.LSTEXT();
            tt.l   = l;
            tt.s   = s;
            tt.day = number;


            travel.destrictions.Add(number, tt);
        }
예제 #12
0
        public ActionResult EditTravel(int id)
        {
            //Lay doi tuong sanpham theo ma
            TRAVEL travel = db.TRAVELs.SingleOrDefault(n => n.ID_TRAVEL == id);

            if (travel == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            //Dua du lieu vao dropdownlist
            //Lay ds tu table phan khuc, sap xep tang dan theo ten phan khuc, chon lay gia tri MaDM, hien thi TenDM
            //ViewBag.MaDM = new SelectList(db.DANHMUCs.ToList().OrderBy(n => n.TenDM), "MaDM", "TenDM", sanpham.MaDM);
            return(View(travel));
        }
예제 #13
0
        // GET: Travel/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRAVEL tRAVEL = db.TRAVELs.Find(id);

            if (tRAVEL == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ID_ARRIVALAGENCY   = new SelectList(db.AGENCies, "ID_AGENCY", "NAME", tRAVEL.ID_ARRIVALAGENCY);
            ViewBag.ID_DEPARTUREAGENCY = new SelectList(db.AGENCies, "ID_AGENCY", "NAME", tRAVEL.ID_DEPARTUREAGENCY);
            ViewBag.ID_PUBLICATION     = new SelectList(db.PUBLICATIONs, "ID_PUBLICATION", "TITLE", tRAVEL.ID_PUBLICATION);
            return(View(tRAVEL));
        }
예제 #14
0
        public void add(TRAVEL travel)
        {
            try
            {
                var Context = new connext_dbEntities();
                Context.TRAVELs.Add(travel);
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
#if DEBUG
                throw new Exception("Impossible de modifier le covoiturage." + Environment.NewLine + ex.StackTrace);
#else
                throw new Exception("Impossible de modifier le covoiturage.");
#endif
            }
        }
예제 #15
0
        public void Insert()
        {
            string   destination, status;
            DateTime departureDate, arrivalDate;
            int      total, categoryId, userId;

            // inputan by user
            Console.Write("Masukkan Departure Date      : ");
            departureDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Arrival Date        : ");
            arrivalDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Destination         : ");
            destination = Console.ReadLine();
            Console.Write("Masukkan Status              : ");
            status = Console.ReadLine();
            Console.Write("Masukkan Total               : ");
            total = Convert.ToInt32(Console.ReadLine());
            Console.Write("Masukkan Category            : ");
            categoryId = Convert.ToInt32(Console.ReadLine());
            Console.Write("Masukkan Id User             : ");
            userId = Convert.ToInt32(Console.ReadLine());

            TRAVEL travels = new TRAVEL()
            {
                departure_date = departureDate,
                arrival_date   = arrivalDate,
                destination    = destination,
                status         = status,
                total          = total,
                category_id    = categoryId,
                user_id        = userId
            };

            try
            {
                context.Travels.Add(travels);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.Write(ex.InnerException);
                Console.Write(ex.Message);
                Console.Write(ex.StackTrace);
            }
        }
예제 #16
0
        public ActionResult CreateTravel(TRAVEL travel, HttpPostedFileBase fileUpload)
        {
            if (db.TRAVELs.Any(x => x.ID_TRAVEL == travel.ID_TRAVEL))
            {
                travel.ID_TRAVEL = db.TRAVELs.Max(x => x.ID_TRAVEL) + 1;
            }
            if (fileUpload == null)
            {
                return(View());
            }

            if (ModelState.IsValid)
            {
                var fileName = Path.GetFileName(fileUpload.FileName);
                //Luu duong dan cua file
                var path = Path.Combine(Server.MapPath("~/Images"), fileName);
                //Kiem tra hinh anh ton tai chua
                if (System.IO.File.Exists(path))
                {
                    ViewBag.Message = "Image was existed ! Please choose another image.";
                    return(View());
                }
                else
                {
                    //Luu hinh anh vao duong dan
                    fileUpload.SaveAs(path);
                    travel.IMAGE_TRAVEL = path;
                }

                try
                {
                    db.TRAVELs.Add(travel);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Error", new { msg = ex.Message }));
                }
            }
            else
            {
                return(View());
            }
            return(RedirectToAction("Travel"));
        }
예제 #17
0
 public ActionResult DeleteTravel(int id, int?aaa)
 {
     try
     {
         TRAVEL travel = db.TRAVELs.SingleOrDefault(n => n.ID_TRAVEL == id);
         if (travel == null)
         {
             Response.StatusCode = 404;
             return(null);
         }
         db.TRAVELs.Remove(travel);
         db.SaveChanges();
         return(RedirectToAction("Travel"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Error", new { msg = ex.Message }));
     }
     //return View();
 }
예제 #18
0
        private string reseatCreateYoutube(TRAVEL travel, string result)
        {
            if (travel.youtubs.Count == 0)
            {
                result = result.Replace("$youtubs", "");
                return(result);
            }

            string tyoutube = CONST.youtubeTravel;
            string youcont  = "";

            foreach (string you in travel.youtubs)
            {
                bool   isOne  = true;
                string itimgs = !isOne ? CONST.youtube1 : CONST.youtube2;
                itimgs  = itimgs.Replace("$srcitem", you);
                youcont = youcont + itimgs;
            }

            tyoutube = tyoutube.Replace("$youitems", youcont);
            result   = result.Replace("$youtubs", tyoutube);
            return(result);
        }
예제 #19
0
        private string reseatTextInfo(TRAVEL travel, string result)
        {
            string licontext = "";

            //тут будем сортированно выводить
            List <TRAVEL.LSTEXT> lstexts = new List <TRAVEL.LSTEXT>();

            foreach (string s in travel.order)
            {
                TRAVEL.LSTEXT item = travel.destrictions[s];
                lstexts.Add(item);
            }

            foreach (TRAVEL.LSTEXT item in lstexts)
            {
                string templ = liItem;
                string iday  = item.day;
                templ = templ.Replace("$Id", iday.ToString());
                string rr = iday == travel.order.First() ? "active" : "";
                templ = templ.Replace("$active", rr);

                licontext = licontext + templ;
            }

            //foreach (KeyValuePair<string, TRAVEL.LSTEXT> keyValue in travel.destrictions)
            //{
            //    string templ = liItem;
            //    string iday = keyValue.Key;
            //    templ = templ.Replace("$Id", iday.ToString());
            //    string rr = iday == "1" ? "active" : "";
            //    templ = templ.Replace("$active", rr);

            //    licontext = licontext + templ;
            //}

            result = result.Replace("$liitems", licontext);



            string dicontext = "";

            foreach (TRAVEL.LSTEXT item in lstexts)
            {
                TRAVEL.LSTEXT val  = item;
                string        lena = val.l;
                lena = lena.Replace("\n", "<br>");

                string templ = diItem;
                string iday  = item.day;
                templ = templ.Replace("$Id", iday.ToString());
                string rr = iday == travel.order.First() ? "active" : "";
                templ = templ.Replace("$active", rr);
                string s1 = "<div class='nametravelwho'>Лена</div><div class='first_div_capital_blue'><p >" + lena + "</p></div>";

                string sergey = val.s;
                sergey = sergey.Replace("\n", "<br>");

                string s2 = "<div class='nametravelwho'>Сергей</div><div class='first_div_capital_green'><p >" + sergey + "</p></div>";;
                templ = templ.Replace("$text", s1 + s2);

                dicontext = dicontext + templ;
            }
            //foreach (KeyValuePair<string, TRAVEL.LSTEXT> keyValue in travel.destrictions)
            //{
            //    TRAVEL.LSTEXT val = keyValue.Value;
            //    string lena = val.l;
            //    lena = lena.Replace("\n", "<br>");

            //    string templ = diItem;
            //    string iday = keyValue.Key;
            //    templ = templ.Replace("$Id", iday.ToString());
            //    string rr = iday == "1" ? "active" : "";
            //    templ = templ.Replace("$active", rr);
            //    string s1 = "<div class='nametravelwho'>Лена</div><div class='first_div_capital_blue'><p >" + lena + "</p></div>";

            //    string sergey = val.s;
            //    sergey = sergey.Replace("\n", "<br>");

            //    string s2 = "<div class='nametravelwho'>Сергей</div><div class='first_div_capital_green'><p >" + sergey + "</p></div>"; ;
            //    templ = templ.Replace("$text", s1 + s2);

            //    dicontext = dicontext + templ;
            //}

            result = result.Replace("$diitems", dicontext);


            return(result);
        }
예제 #20
0
        public int Update(int input)
        {
            string   destination, status;
            DateTime departureDate, arrivalDate;
            int      total, categoryId;

            var temp = from t in context.Travels.ToList()
                       join u in context.Users.ToList()
                       on t.user_id equals u.user_id
                       where t.travel_id == input
                       select t;

            TRAVEL travels = context.Travels.Find(input);

            Console.WriteLine("--------Data sebelum di Update--------\n");
            Console.WriteLine("Nama User        : "******"Category         : " + travels.category_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id               : " + travels.travel_id);
            Console.WriteLine("Departure Date   : " + travels.departure_date);
            Console.WriteLine("Arrival Date     : " + travels.arrival_date);
            Console.WriteLine("Destination      : " + travels.destination);
            Console.WriteLine("Status           : " + travels.status);
            Console.WriteLine("Total            : " + travels.total);
            Console.WriteLine("------------------------\n");

            // inputan by user
            Console.Write("Masukkan Departure Date      : ");
            departureDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Arrival Date        : ");
            arrivalDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Destination         : ");
            destination = Console.ReadLine();
            Console.Write("Masukkan Status              : ");
            status = Console.ReadLine();
            Console.Write("Masukkan Total               : ");
            total = Convert.ToInt32(Console.ReadLine());
            Console.Write("Masukkan Category            : ");
            categoryId = Convert.ToInt32(Console.ReadLine());

            /*Console.Write("Masukkan Id User             : "******"\n--------Data setelah di Update--------\n");
            Console.WriteLine("Nama User        : "******"Category         : " + tRAVEL.category_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id               : " + tRAVEL.travel_id);
            Console.WriteLine("Departure Date   : " + tRAVEL.departure_date);
            Console.WriteLine("Arrival Date     : " + tRAVEL.arrival_date);
            Console.WriteLine("Destination      : " + tRAVEL.destination);
            Console.WriteLine("Status           : " + tRAVEL.status);
            Console.WriteLine("Total            : " + tRAVEL.total);
            Console.WriteLine("-------------------------");

            return(input);
        }
예제 #21
0
        //берем определенное путешествие
        public static TRAVEL getTravel(int id)
        {
            TRAVEL travel = null;

            return(_TRAVELS.FirstOrDefault(o => o.Id == id));
        }
예제 #22
0
        public void createTravel(DirectoryInfo f)
        {
            TRAVEL travel = new TRAVEL();
            string name   = f.Name;

            travel.dataFolderPath = f.FullName;

            travel.Id = Convert.ToInt32(name);
            string content = FILEWORK.ReadFileContent(f.FullName + "//info.txt");

            String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None);


            #region parse order.txt
            string   order       = FILEWORK.ReadFileContent(f.FullName + "//order.txt");
            String[] order_lines = order.Split(new string[] { "\n" }, StringSplitOptions.None);
            travel.order = order_lines.ToList();
            #endregion

            #region youtubs.txt

            if (File.Exists(f.FullName + "//youtubs.txt"))
            {
                string   ycontent       = FILEWORK.ReadFileContent(f.FullName + "//youtubs.txt");
                String[] ycontent_lines = ycontent.Split(new string[] { "\n" }, StringSplitOptions.None);
                foreach (var you in ycontent_lines)
                {
                    string syou = parseYoutubs(you);
                    travel.youtubs.Add(syou);
                }
            }
            #endregion



            travel.description = FILEWORK.ReadFileContent(f.FullName + "//description.txt");

            foreach (string line in lines)
            {
                if (String.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (travel.name == null)
                {
                    travel.name = line;
                    continue;
                }

                if (travel.ldate == null)
                {
                    travel.ldate = line;
                    continue;
                }

                if (travel.lcount == null)
                {
                    travel.lcount = line;
                    continue;
                }

                if (line.Contains(".jpg"))
                {
                    travel.mainIng.Add(line);
                    continue;
                }

                if (travel.praceS == null)
                {
                    travel.praceS = line;
                    continue;
                }



                if (travel.praceL == null)
                {
                    travel.praceL = line;
                    continue;
                }
            }



            List <string> imgs = new List <string>();
            travel.imgs = FILEWORK.GetAllFiles(travel.dataFolderPath, imgs, ".jpg");

            List <string> txts = new List <string>();
            txts = FILEWORK.GetAllFiles(travel.dataFolderPath, txts, ".txt");
            foreach (string s in txts)
            {
                FileInfo ff        = new FileInfo(s);
                string   fname     = ff.Name;
                String[] ll        = fname.Split(new string[] { ".txt" }, StringSplitOptions.None);
                string   shortName = ll[0];
                bool     success   = travel.order.Contains(shortName);
                if (success)
                {
                    addLSText(shortName, travel, ff.FullName);
                }
            }

            DATA._TRAVELS.Add(travel);
        }
예제 #23
0
        public ActionResult CreateTravel()
        {
            TRAVEL model = new TRAVEL();

            return(View(model));
        }