예제 #1
0
        public JsonResult GetData(int idBV)
        {
            BaiViet      bv   = db.BaiViets.Where(x => x.idBV == idBV).SingleOrDefault();
            NhaTro       nt   = db.NhaTroes.Where(x => x.idNT == bv.idNT).SingleOrDefault();
            PostingModel view = new PostingModel();

            view.TieuDe    = bv.TieuDe;
            view.TieuDePhu = bv.TieuDePhu;
            view.NgayDang  = bv.NgayDang;
            view.DienTich  = nt.DienTich;
            view.Lau       = (int)nt.Lau;
            view.PhongNgu  = (int)nt.PhongNgu;
            view.NhaTam    = (int)nt.NhaTam;
            view.MoTa      = bv.MoTa;
            view.SoNha     = nt.SoNha;
            view.Gia       = (int)nt.Gia;
            view.idQuan    = (int)nt.idQuan;
            view.idPhuong  = (int)nt.idPhuong;
            view.idBV      = idBV;
            string value = string.Empty;

            value = JsonConvert.SerializeObject(view, Formatting.Indented, new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult SuaBaiViet(PostingModel model)
        {
            BaiViet bv = db.BaiViets.Find(model.idBV);
            NhaTro  nt = db.NhaTroes.Find(bv.idNT);

            bv.TieuDe    = model.TieuDe;
            bv.TieuDePhu = model.TieuDePhu;
            bv.MoTa      = model.MoTa;

            nt.SoNha    = model.SoNha;
            nt.Gia      = model.Gia;
            nt.Lau      = model.Lau;
            nt.idPhuong = model.idPhuong;
            nt.idQuan   = model.idQuan;
            nt.PhongNgu = model.PhongNgu;
            nt.NhaTam   = model.NhaTam;

            var bvdao = new BaiVietDAO();

            bvdao.Update(bv);
            var ntdao = new NhaTroDAO();
            int idnt  = (int)bv.idNT;

            ntdao.Update(nt, idnt);

            return(RedirectToAction("PostsManager", "Posting"));
        }
 public Page_DetailNhaTro()
 {
     InitializeComponent();
     item       = new NhaTro();
     _tooltip   = new USCustomPushpin();
     Infoex     = new NhaTro();
     itemInlist = new NhaTro();
 }
예제 #4
0
        public int Update(BaiViet model1, int id, NhaTro model2)
        {
            //BaiViet dbEntry = db.BaiViets.Find(id);
            //if (dbEntry == null)
            //{
            //    return null;
            //}

            db.SaveChanges();
            return(model1.idBV);
        }
예제 #5
0
        public int Update(NhaTro model, int id)
        {
            NhaTro dbEntry = dbContext.NhaTroes.Find(id);

            if (dbEntry == null)
            {
                return(0);
            }
            dbContext.SaveChanges();
            return(model.idNT);
        }
예제 #6
0
 public bool postNhaTro(NhaTro nhatro)
 {
     try
     {
         db.NhaTroes.Add(nhatro);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //if (AppManagement._flagsaveNTTrangChu == true)
            //    NavigationService.GoBack();
            if (AppManagement._flagHouseSave == false)
            {
                string _url = "";
                _url = AppManagement._URI + "task=getRoomsByIds&scope=title,description,id,address&link=1&rids=" + AppManagement.listPivot.ElementAt(0).id + "&num=1";
                HttpClient client   = new HttpClient();
                var        response = await client.GetStringAsync(new Uri(_url));

                var data = JsonConvert.DeserializeObject <IDictionary <string, object> >(response)["data"];
                AppManagement.ListInfoExtend.ListInfoExtends = JsonConvert.DeserializeObject <List <InfoExtends> >(data.ToString());
                getItem();
                pivotNT.ItemsSource             = AppManagement.listPivot;
                AppManagement._flagnavigateBack = true;
                AppManagement._flagFillMarker   = true;
                item = pivotNT.Items.ElementAt(0) as NhaTro;

                itemInlist = AppManagement.list.FirstOrDefault(r => r.id == item.id);
                _tooltip   = AppManagement._list_marker.FirstOrDefault(r => r.TagId == item.id);

                if (item.flagColor == 1)
                {
                    item.flagColor       = 2;
                    itemInlist.flagColor = 2;
                    if (AppManagement._nhadaxem == null)
                    {
                        AppManagement._nhadaxem = new List <NhaTro>();
                    }
                    AppManagement._nhadaxem.Add(item);
                    Controller_Read_Write_NhaTro.WriteNhaXem();
                }

                _tooltip.ColorMarker = item.flagColor.ToString();
                _tooltip.FillMarker();
                iconStar.Source = new BitmapImage(new Uri(item.link, UriKind.Relative));
            }
            else
            {
                pivotNT.ItemsSource             = AppManagement.listPivot;
                AppManagement._flagnavigateBack = true;
                AppManagement._flagFillMarker   = true;
                item            = pivotNT.Items.ElementAt(0) as NhaTro;
                iconStar.Source = new BitmapImage(new Uri(item.link, UriKind.Relative));
            }
        }
예제 #8
0
        public ActionResult Posting(PostingModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.ImageUpload != null)
                {
                    string fileName = Path.GetFileNameWithoutExtension(model.ImageUpload.FileName);
                    //string extension = Path.GetExtension(model.ImageUpload.FileName);
                    //file.SaveAs(Server.MapPath("~/Content/Images/" + file.FileName));
                    model.Images = "~/Content/Images/" + fileName;
                }
                var daoNT   = new NhaTroDAO();
                var daoPost = new BaiVietDAO();

                var bv = new BaiViet();
                var nt = new NhaTro();

                nt.DienTich = model.DienTich;
                nt.PhongNgu = model.PhongNgu;
                nt.Lau      = model.Lau;
                nt.NhaTam   = model.NhaTam;
                nt.Gia      = model.Gia;
                nt.SoNha    = model.SoNha;
                nt.idPhuong = model.idPhuong;
                nt.Image    = model.Images;
                nt.idQuan   = model.idQuan;
                daoNT.Insert(nt);

                NhaTro temp = db.NhaTroes.OrderByDescending(p => p.idNT).FirstOrDefault();
                bv.TieuDe    = model.TieuDe;
                bv.TieuDePhu = model.TieuDePhu;
                bv.MoTa      = model.MoTa;
                bv.TrangThai = false;
                DateTime now = DateTime.Now;
                bv.NgayDang = now;
                bv.idNT     = temp.idNT;
                var      session = (DACN.Common.UserLogin)Session[DACN.Common.CommonConstants.USER_SESSION];
                string   ten     = session.UserName;
                TaiKhoan tk      = db.TaiKhoans.Find(session.userID);
                bv.idTK = tk.idTK;
                daoPost.Insert(bv);
            }
            return(View("Posted", model));
        }
예제 #9
0
        public IEnumerable <NhaTro> getNhaTro()
        {
            List <NhaTro> temp = new List <NhaTro>();

            for (int i = 0; i < db.NhaTroes.Count(); i++)
            {
                NhaTro t = new NhaTro();
                temp.Add(t);
                temp[i].IDNhaTro    = db.NhaTroes.ToList()[i].IDNhaTro;
                temp[i].IDNguoiDang = db.NhaTroes.ToList()[i].IDNguoiDang;
                temp[i].DienTich    = db.NhaTroes.ToList()[i].DienTich;
                temp[i].SoNha       = db.NhaTroes.ToList()[i].SoNha;
                temp[i].GiaPhong    = db.NhaTroes.ToList()[i].GiaPhong;
                temp[i].MaDuong     = db.NhaTroes.ToList()[i].MaDuong;
                temp[i].MaPhuong    = db.NhaTroes.ToList()[i].MaPhuong;
                temp[i].MaQuanHuyen = db.NhaTroes.ToList()[i].MaQuanHuyen;
                temp[i].MaTinhThanh = db.NhaTroes.ToList()[i].MaTinhThanh;
                temp[i].TinhTrang   = db.NhaTroes.ToList()[i].TinhTrang;
                temp[i].HinhAnh     = db.NhaTroes.ToList()[i].HinhAnh;
            }

            return(temp);
        }
예제 #10
0
 public int Insert(NhaTro model)
 {
     return(model.idNT);
 }
예제 #11
0
 public int Insert(NhaTro model)
 {
     dbContext.NhaTroes.Add(model);
     dbContext.SaveChanges();
     return(model.idNT);
 }