Beispiel #1
0
        public ActionResult GetAttrPic(String id)
        {
            id = id.Replace(".jpg", "");
            dbDataContext db = new dbDataContext();
            Attributes rec = db.Attributes.Where(c => c.id == Int32.Parse(id)).Single();

            return File(rec.picture.ToArray(), "image/jpeg");
        }
Beispiel #2
0
        public ActionResult CreateLanguage(languages model)
        {
            dbDataContext db = new dbDataContext();

            db.languages.InsertOnSubmit(model);
            db.SubmitChanges();

            return RedirectToAction("LangugeList");
        }
Beispiel #3
0
        public ActionResult Econom()
        {
            InitSettings();
            dbDataContext db = new dbDataContext();
            List<Objects> lst_obj = db.Objects.Select(c => c).Where(c => c.type == 3).ToList<Objects>();
            ViewBag.list = lst_obj;

            List<Objects_Attributes> obj_attr_list = db.Objects_Attributes.Select(c => c).Where(c => c.Objects.type == 3).ToList<Objects_Attributes>();
            ViewBag.obj_attr_list = obj_attr_list;

            return View();
        }
Beispiel #4
0
 public ActionResult AttributesList()
 {
     List<String> lst_pics = new List<string>();
     dbDataContext db = new dbDataContext();
     List<Attributes> lst = db.Attributes.Select(c => c).OrderBy(c => c.attr_key).ToList();
     foreach (Attributes attrs in lst)
     {
         lst_pics.Add("data:image/jpeg;base64," + attrs.picture.ToString().Replace("\"", ""));
     }
     ViewBag.pics = lst_pics;
     return View(lst);
 }
Beispiel #5
0
        public ActionResult GetPictureF2(String id)
        {
            id = id.Replace(".jpg", "");
            dbDataContext db = new dbDataContext();
            Objects rec = db.Objects.SingleOrDefault(c => c.ID == Int32.Parse(id));
            if (rec.pic2 == null)
            {
                byte[] arr = new byte[0];
                return File(arr, "image/jpeg");
            }

            return File(rec.pic2.ToArray(), "image/jpeg");
        }
Beispiel #6
0
        // GET: Pages
        public ActionResult Index(string id="")
        {
            InitSettings();
            if (id == "")
            {
                return RedirectToAction("Index", "Home");
            }
            dbDataContext db = new dbDataContext();

            var page = db.Pages.SingleOrDefault(c => c.Alias == id);
            if (page==null)
                return RedirectToAction("Index", "Home");
            ViewBag.id = page.id;
            ViewBag.name = page.Naim;
            ViewBag.alias = page.Alias;
            ViewBag.html = page.Text;

            return View();
        }
Beispiel #7
0
        public ActionResult CreateAttribute(FormCollection coll)
        {
            dbDataContext db = new dbDataContext();

            Attributes attr = new Attributes();
            attr.attr_key = Request["attr_key"];

            HttpPostedFileBase file = Request.Files[0];
            MemoryStream ms = new MemoryStream();
            Image img = Image.FromStream(file.InputStream);
            img.Save(ms, img.RawFormat);
            Binary bin = new Binary(ms.ToArray());
            attr.picture = bin;

            db.Attributes.InsertOnSubmit(attr);
            db.SubmitChanges();

            return RedirectToAction("AttributesList");
        }
Beispiel #8
0
        public ActionResult ReViewDetails(int id)
        {
            InitSettings();
            dbDataContext db = new dbDataContext();
            Rating rating_obj = db.Rating.SingleOrDefault(c => c.ID==id);
            if (rating_obj == null)
                return RedirectToAction("ReViews");

            List<reviews> rw_list = db.reviews.Select(c => c).Where(c=>c.object_id==id).OrderByDescending(c => c.data).ToList<reviews>();
            ViewBag.rw_list = rw_list;

            return View(rating_obj);
        }
Beispiel #9
0
        public ActionResult ReViews()
        {
            InitSettings();
            dbDataContext db = new dbDataContext();
            List<Rating> lst = db.Rating.Select(c=>c).OrderByDescending(c=>c.rating).ToList<Rating>();

            List<reviews> rw_list = db.reviews.Select(c => c).OrderBy(c => c.object_id).ToList<reviews>();
            ViewBag.rw_list = rw_list;
            return View(lst);
        }
Beispiel #10
0
        public ActionResult CreateObjects()
        {
            dbDataContext db = new dbDataContext();
            List<Flats.Views.Manage.Region> lst = db.Region.Select(c => c).OrderBy(c => c.Naim).ToList<Flats.Views.Manage.Region>();
            ViewBag.regions = lst;
            List<LiveConditions> lc_lst = db.LiveConditions.Select(c => c).OrderBy(c => c.lc_key).ToList<LiveConditions>();
            ViewBag.lc_lst = lc_lst;
            List<Attributes> attrs = db.Attributes.Select(c => c).OrderBy(c => c.attr_key).ToList<Attributes>();
            ViewBag.attrs = attrs;
            List<String> lst_pics = new List<string>();
            foreach (Attributes attr in attrs)
            {
                lst_pics.Add("data:image/jpeg;base64," + attr.picture.ToString().Replace("\"", ""));
            }
            ViewBag.pics = lst_pics;

            return View();
        }
Beispiel #11
0
        public ActionResult Object(int id)
        {
            InitSettings();
            dbDataContext db = new dbDataContext();
            Objects obj = db.Objects.SingleOrDefault(c=>c.ID==id);
            if (obj == null)
                return RedirectToAction("Index");

            List<Objects_Attributes> obj_attr_list = db.Objects_Attributes.Select(c => c).Where(c => c.Objects.ID == id).ToList<Objects_Attributes>();
            ViewBag.obj_attr_list = obj_attr_list;
            List<Objects_LiveConditions> obj_lc_list = db.Objects_LiveConditions.Select(c => c).Where(c => c.object_id == id).ToList<Objects_LiveConditions>();
            ViewBag.obj_lc_list = obj_lc_list;

            List<reviews> rw_list = db.reviews.Select(c => c).Where(c => c.object_id == id).ToList<reviews>();
            ViewBag.rw_list = rw_list;

            return View(obj);
        }
Beispiel #12
0
        public ActionResult EditObjects(int id)
        {
            if (id == 0)
                return RedirectToAction("ObjectsList");
            dbDataContext db = new dbDataContext();
            Objects ft = db.Objects.SingleOrDefault(c => c.ID == id);
            if (ft == null)
            {
                return RedirectToAction("ObjectsList");
            }
            List<Flats.Views.Manage.Region> lst = db.Region.Select(c => c).OrderBy(c => c.Naim).ToList<Flats.Views.Manage.Region>();
            ViewBag.regions = lst;

            List<LiveConditions> lc_lst = db.LiveConditions.Select(c => c).OrderBy(c => c.lc_key).ToList<LiveConditions>();
            ViewBag.lc_lst = lc_lst;
            List<Objects_LiveConditions> used_lc_list = db.Objects_LiveConditions.Select(c => c).Where(c => c.object_id == id).ToList<Objects_LiveConditions>();
            ViewBag.used_lc_list = used_lc_list;

            List<Attributes> attrs = db.Attributes.Select(c => c).OrderBy(c => c.attr_key).ToList<Attributes>();
            ViewBag.attrs = attrs;

            List<Objects_Attributes> used_attr = db.Objects_Attributes.Select(c => c).Where(c => c.object_id == id).ToList<Objects_Attributes>();
            List<int> ua = new List<int>();
            foreach (Objects_Attributes oa in used_attr)
            {
                ua.Add(oa.attribute_id);
            }
            ViewBag.ua_list = ua;

            List<String> lst_pics = new List<string>();
            foreach (Attributes attr in attrs)
            {
                lst_pics.Add("data:image/jpeg;base64," + attr.picture.ToString().Replace("\"", ""));
            }
            ViewBag.pics = lst_pics;
            return View(ft);
        }
Beispiel #13
0
        public ActionResult EditTranslate(Translate model)
        {
            dbDataContext db = new dbDataContext();

            Translate rec = db.Translate.SingleOrDefault(c => c.ID == model.ID);
            if (rec == null)
                return RedirectToAction("TranslateList");

            rec.LanguageID = Int32.Parse(Request["Lang"]);
            rec.PhraseID = Int32.Parse(Request["Phrase"]);
            rec.Translation = model.Translation;

            db.SubmitChanges();

            return RedirectToAction("TranslateList");
        }
Beispiel #14
0
        public ActionResult SendBron()
        {
            int id = Int32.Parse(Request["id"]);
            string name = Request["name"];
            string surname = Request["surname"];
            string email = Request["email"];
            string phone = Request["phone"];
            string kolvo = Request["kolvo"];
            string bron_date1 = Request["bron_date1"];
            string bron_date2 = Request["bron_date2"];

            dbDataContext db = new dbDataContext();
            Objects obj = db.Objects.SingleOrDefault(c=>c.ID==id);

            if (obj==null)
                return Json(new { message = "Ошибка отправки письма" });

            MailMessage Message = new MailMessage();
            Message.Subject = "Бронирование объекта";
            string template = "<html><body>Адрес объекта:{0}<br/>Имя заказчика:{1}<br/>"+
                "Фамилия заказчика:{2}<br/>E-mail заказчика:{3}<br/>" +
                "Номер телефона заказчика:{4}<br/>Количество гостей:{5}<br/>" +
                "Дата заезда:{6}<br/>Дата выезда:{7}<br/>" +
                "</body></html>";
            String MessageBody = String.Format(template, obj.address, name, surname, email, phone, kolvo, bron_date1, bron_date2);

            Message.Body = MessageBody;
            Message.From = new System.Net.Mail.MailAddress("*****@*****.**");
            Message.To.Add(new MailAddress("*****@*****.**"));
            Message.IsBodyHtml = true;

            System.Net.Mail.SmtpClient Smtp = new SmtpClient("smtp.mail.ru", 587);
            Smtp.EnableSsl = true;
            Smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "1984PassPass1984");

            Smtp.Send(Message);
            return Json(new { message = "Письмо отправлено" });
        }
Beispiel #15
0
        public ActionResult EditPage(Pages model)
        {
            dbDataContext db = new dbDataContext();
            Pages page = db.Pages.SingleOrDefault(c => c.id == model.id);
            if (page == null)
            {
                return RedirectToAction("PagesList");
            }

            page.Alias = model.Alias;
            page.Naim = model.Naim;
            page.Text = model.Text;

            db.SubmitChanges();
            return RedirectToAction("PagesList");
        }
Beispiel #16
0
        public ActionResult EditRegion(Flats.Views.Manage.Region model)
        {
            dbDataContext db = new dbDataContext();
            Flats.Views.Manage.Region ft = db.Region.SingleOrDefault(c => c.ID == model.ID);
            if (ft == null)
            {
                return RedirectToAction("RegionList");
            }

            ft.Naim = model.Naim;

            db.SubmitChanges();
            return RedirectToAction("RegionList");
        }
Beispiel #17
0
 public ActionResult EditSetting(int id=0)
 {
     if (id == 0)
         return RedirectToAction("Index");
     dbDataContext db = new dbDataContext();
     Settings sett = db.Settings.SingleOrDefault(c => c.id == id);
     if (sett == null)
     {
         return RedirectToAction("Index");
     }
     return View(sett);
 }
Beispiel #18
0
 public ActionResult EditRegion(int id = 0)
 {
     if (id == 0)
         return RedirectToAction("RegionList");
     dbDataContext db = new dbDataContext();
     Flats.Views.Manage.Region ft = db.Region.SingleOrDefault(c => c.ID == id);
     if (ft == null)
     {
         return RedirectToAction("RegionList");
     }
     return View(ft);
 }
Beispiel #19
0
        public ActionResult EditPhrase(Phrase model)
        {
            dbDataContext db = new dbDataContext();

            Phrase ph = db.Phrase.SingleOrDefault(c => c.id == model.id);
            if (ph == null)
            {
                return RedirectToAction("PhrasesList");
            }
            ph.phrase_key = model.phrase_key;

            db.SubmitChanges();

            return RedirectToAction("PhrasesList");
        }
Beispiel #20
0
 public ActionResult EditPhrase(int id)
 {
     dbDataContext db = new dbDataContext();
     Phrase rec = db.Phrase.SingleOrDefault(c => c.id == id);
     if (rec == null)
         return RedirectToAction("PhrasesList");
     return View(rec);
 }
Beispiel #21
0
        public ActionResult SaveReview()
        {
            String name = Request["name"];
            String surname = Request["surname"];
            String text = Request["text"];
            String total = Request["total"];
            String region = Request["region"];
            String comfort = Request["comfort"];
            String clean = Request["clean"];
            String price = Request["price"];
            String services = Request["services"];
            int id = Int32.Parse(Request["id"]);

            dbDataContext db = new dbDataContext();

            reviews rw = new reviews();
            rw.data = DateTime.Now;
            rw.cleaness = Decimal.Parse(clean.Replace('.',','));
            rw.price = Decimal.Parse(price.Replace('.', ','));
            rw.services = Decimal.Parse(services.Replace('.', ','));
            rw.comfort = Decimal.Parse(comfort.Replace('.', ','));
            rw.region = Decimal.Parse(region.Replace('.', ','));
            rw.object_id = id;
            rw.header = name + " " + surname;
            rw.body = text;
            rw.total = Decimal.Parse(total.Replace('.', ','));
            rw.Name = name;
            rw.Surname = surname;

            db.reviews.InsertOnSubmit(rw);
            db.SubmitChanges();

            return RedirectToAction("ReViewDetails", new { id = rw.id });
        }
Beispiel #22
0
 public ActionResult EditLiveCondition(int id = 0)
 {
     if (id == 0)
         return RedirectToAction("LiveConditionsList");
     dbDataContext db = new dbDataContext();
     LiveConditions lc = db.LiveConditions.SingleOrDefault(c => c.id == id);
     if (lc == null)
     {
         return RedirectToAction("LiveConditionsList");
     }
     return View(lc);
 }
Beispiel #23
0
        public ActionResult Search(FormCollection coll)
        {
            InitSettings();
            dbDataContext db = new dbDataContext();
            var recs = db.Objects.Select(c => c);

            if (Request["region"] != String.Empty)
                recs = recs.Where(c => c.Region.Naim == Request["region"]);

            if (Request["rooms"] != String.Empty)
            {
                int rooms = Int32.Parse(Request["rooms"].ToString().Substring(0,1));

                recs = recs.Where(c => c.rooms_count == rooms);
            }

            if (Request["guests"] != String.Empty)
            {
                int guests = Int32.Parse(Request["guests"].ToString().Substring(0, 1));

                recs = recs.Where(c => c.guests_count >= guests);
            }

            if (Request["amount"] != String.Empty)
            {
                string money = Request["amount"].ToString().Replace("от ", "").Replace("до ", "").Replace("грн.", "");
                int from = Int32.Parse(money.Split(' ')[0].Trim());
                int to = Int32.Parse(money.Split(' ')[2].Trim());

                recs = recs.Where(c => c.price1 >= from);
                recs = recs.Where(c => c.price1 <= to);
            }

            ViewBag.list = recs.ToList<Objects>();

            List<Objects_Attributes> obj_attr_list = db.Objects_Attributes.Select(c => c).Where(c => c.Objects.type == 2).ToList<Objects_Attributes>();
            ViewBag.obj_attr_list = obj_attr_list;

            return View();
        }
Beispiel #24
0
 public ActionResult EditPage(int id = 0)
 {
     if (id == 0)
         return RedirectToAction("PagesList");
     dbDataContext db = new dbDataContext();
     Pages page = db.Pages.SingleOrDefault(c => c.id == id);
     if (page == null)
     {
         return RedirectToAction("PagesList");
     }
     return View(page);
 }
Beispiel #25
0
        public ActionResult EditLiveCondition(LiveConditions model)
        {
            dbDataContext db = new dbDataContext();
            LiveConditions lc = db.LiveConditions.SingleOrDefault(c => c.id == model.id);
            if (lc == null)
            {
                return RedirectToAction("LiveConditionsList");
            }

            lc.lc_key = model.lc_key;
            lc.lc_value = model.lc_value;

            db.SubmitChanges();
            return RedirectToAction("LiveConditionsList");
        }
Beispiel #26
0
 public ActionResult EditTranslate(int id)
 {
     dbDataContext db = new dbDataContext();
     Translate rec = db.Translate.SingleOrDefault(c => c.ID == id);
     if (rec == null)
         return RedirectToAction("TranslateList");
     ViewBag.phrase_list = db.Phrase.Select(c => c).OrderBy(c => c.phrase_key).ToList<Phrase>();
     ViewBag.lang_list = db.languages.Select(c => c).OrderBy(c => c.short_code).ToList<languages>();
     return View(rec);
 }
Beispiel #27
0
        public ActionResult CreateLiveCondition(LiveConditions model)
        {
            dbDataContext db = new dbDataContext();

            db.LiveConditions.InsertOnSubmit(model);
            db.SubmitChanges();

            return RedirectToAction("LiveConditionsList");
        }
Beispiel #28
0
        public ActionResult EditObjects(FormCollection coll)
        {
            dbDataContext db = new dbDataContext();
            int obj_id;
            try
            {
                obj_id = Int32.Parse(coll["obj_id"]);
            }
            catch
            {
                return RedirectToAction("ObjectsList");
            }

            Objects obj = db.Objects.SingleOrDefault(c=>c.ID==obj_id);
            if (obj == null)
            {
                return RedirectToAction("ObjectsList");
            }

            obj.type = Int32.Parse(coll["FlatType"]);
            obj.region_id = Int32.Parse(coll["Region"]);
            obj.header = coll["header"];
            obj.address = coll["address"];
            if (coll["rooms_count"] != String.Empty)
                obj.rooms_count = Int32.Parse(coll["rooms_count"]);
            else
                obj.rooms_count = 0;
            if (coll["guests_count"] != String.Empty)
                obj.guests_count = Int32.Parse(coll["guests_count"]);
            else
                obj.guests_count = 0;

            if (coll["price1"] != String.Empty)
                obj.price1 = Decimal.Parse(coll["price1"]);
            else obj.price1 = 0;

            if (coll["price2"] != String.Empty)
                obj.price2 = Decimal.Parse(coll["price2"]);
            else
                obj.price2 = 0;

            if (coll["price5"] != String.Empty)
                obj.price5 = Decimal.Parse(coll["price5"]);
            else obj.price5 = 0;
            if (coll["price14"] != String.Empty)
                obj.price14 = Decimal.Parse(coll["price14"]);
            else
                obj.price14 = 0;

            obj.desc_body = coll["desc"];

            //Записываем картинки

            HttpPostedFileBase file = Request.Files["large_foto1"];
            MemoryStream ms;
            Image img;
            Binary bin;

            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic1large = bin;
            }

            file = Request.Files["large_foto2"];
            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic2large = bin;
            }

            file = Request.Files["foto1"];
            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic1 = bin;
            }

            file = Request.Files["foto2"];
            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic2 = bin;
            }

            file = Request.Files["foto3"];
            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic3 = bin;
            }

            file = Request.Files["foto4"];
            if (file.ContentLength != 0)
            {
                ms = new MemoryStream();
                img = Image.FromStream(file.InputStream);
                img.Save(ms, img.RawFormat);
                bin = new Binary(ms.ToArray());
                obj.pic4 = bin;
            }//--Записываем картинки

            db.SubmitChanges();

            //Чистим таблицы- связки
            List<Objects_LiveConditions> olc_list = db.Objects_LiveConditions.Select(p => p).Where(p => p.object_id == obj.ID).ToList<Objects_LiveConditions>();
            foreach (Objects_LiveConditions olc in olc_list)
            {
                db.Objects_LiveConditions.DeleteOnSubmit(olc);
            }
            List<Objects_Attributes> oattr_list = db.Objects_Attributes.Select(p => p).Where(p => p.object_id == obj.ID).ToList<Objects_Attributes>();
            foreach (Objects_Attributes olc in oattr_list)
            {
                db.Objects_Attributes.DeleteOnSubmit(olc);
            }

            db.SubmitChanges();

            //Записываем жизненные условия
            var lcs = coll.AllKeys.Where(c => (c.StartsWith("lc_") & (!c.Contains("val"))));

            foreach (var attr in lcs)
            {
                string temp_key = attr.Replace("lc_", "lc_val_");
                string temp_value = coll[temp_key];
                Objects_LiveConditions olc = new Objects_LiveConditions();
                olc.lc_id = Int32.Parse(attr.Replace("lc_", ""));
                olc.object_id = obj.ID;
                olc._value = temp_value;
                db.Objects_LiveConditions.InsertOnSubmit(olc);
            }

            var attrs = coll.AllKeys.Where(c => (c.StartsWith("attr_")));

            foreach (var attr in attrs)
            {
                string temp_id = attr.Replace("attr_", "");
                Objects_Attributes oattr = new Objects_Attributes();
                oattr.attribute_id = Int32.Parse(temp_id);
                oattr.object_id = obj.ID;
                db.Objects_Attributes.InsertOnSubmit(oattr);
            }

            db.SubmitChanges();

            return RedirectToAction("ObjectsList");
        }
Beispiel #29
0
        private void InitSettings()
        {
            dbDataContext db = new dbDataContext();
            List<Settings> Sett = db.Settings.Select(c => c).OrderBy(c => c.setting_key).ToList();
            Hashtable arr = new Hashtable();

            foreach (Settings item in Sett)
                arr.Add(item.setting_key, item.setting_value);
            ViewBag.settings = arr;

            List<Pages> pages_list = db.Pages.Select(c => c).OrderBy(c => c.Naim).ToList<Pages>();
            ViewBag.pages_list = pages_list;

            List<Region> list_region = db.Region.Select(c => c).OrderBy(c => c.Naim).ToList<Region>();
            ViewBag.regions = list_region;

            //Подтягиваем курсы валют
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://bank-ua.com/export/currrate.xml");
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.GetEncoding(1251));
            String doc = reader.ReadToEnd();
            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(doc);
            XmlElement xRoot = xDoc.DocumentElement;
            //доллары
            XmlNode xnode = xRoot.SelectSingleNode(".//code[text()='840']");
            String UsdRate = (xnode.ParentNode).ChildNodes[5].InnerText.Split('.')[0];
            ViewBag.UsdRate = UsdRate.Substring(0, 2) + "," + UsdRate.Substring(2, 2);
            if ((xnode.ParentNode).ChildNodes[6].InnerText.Substring(0, 1) == "-")
                ViewBag.UsdDir = "˅";
            else
                ViewBag.UsdDir = "˄";

            //евро
            xnode = xRoot.SelectSingleNode(".//code[text()='978']");
            String EurRate = (xnode.ParentNode).ChildNodes[5].InnerText.Split('.')[0];
            ViewBag.EurRate = EurRate.Substring(0, 2) + "," + EurRate.Substring(2, 2);
            if ((xnode.ParentNode).ChildNodes[6].InnerText.Substring(0, 1) == "-")
                ViewBag.EurDir = "˅";
            else
                ViewBag.EurDir = "˄";

            //Подтягиваем погоду
            req = (HttpWebRequest)HttpWebRequest.Create("https://export.yandex.ru/weather-ng/forecasts/33837.xml");
            resp = (HttpWebResponse)req.GetResponse();
            reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
            doc = reader.ReadToEnd();
            xDoc = new XmlDocument();
            xDoc.LoadXml(doc);
            xRoot = xDoc.DocumentElement;

            ViewBag.temperature_value = xRoot.ChildNodes[0].ChildNodes[4].InnerText;
            ViewBag.temperature_color = xRoot.ChildNodes[0].ChildNodes[4].Attributes[0].Value;

            xnode = xRoot.ChildNodes[0].ChildNodes[8];
            ViewBag.temperature_pic = "http://yandex.st/weather/1.1.78/i/icons/48x48/" + xnode.InnerText + ".png";

            xRoot = xDoc.DocumentElement;
            ViewBag.isMainPage = false;

            //languages
            if (Session.IsNewSession)
            {
                Session.Add("lang", "ru");
            }
            string lang = Session["lang"].ToString();

            List<Translate> lang_list = db.Translate.Select(c => c).Where(c => c.languages.short_code.ToLower().Trim() == lang.ToLower().Trim()).ToList<Translate>();
            Dictionary<String, String> lang_arr = new Dictionary<string, string>();
            foreach (Translate tran in lang_list)
            {
                if (!lang_arr.ContainsKey(tran.Phrase.phrase_key))
                    lang_arr.Add(tran.Phrase.phrase_key, tran.Translation);
            }

            foreach (Phrase ph in db.Phrase.Select(c => c))
            {
                if (!lang_arr.ContainsKey(ph.phrase_key))
                    lang_arr.Add(ph.phrase_key, ph.phrase_key);
            }

            ViewBag.Translation = lang_arr;
            //--languages
        }
Beispiel #30
0
        public ActionResult EditSetting(Settings model)
        {
            dbDataContext db = new dbDataContext();
            Settings sett = db.Settings.SingleOrDefault(c => c.id == model.id);
            if (sett == null)
            {
                return RedirectToAction("Index");
            }
            sett.setting_key = model.setting_key;
            sett.setting_value = model.setting_value;

            db.SubmitChanges();
            return RedirectToAction("Index");
        }