Esempio n. 1
0
        public ActionResult CreateHotel(hotel_info hotel_info)
        {
               
            try
            {
               
                //hotel_info.u_id = new HotelInfoHelp().getUId();
                hotel_info.source_id = Convert.ToInt32(help.StringHelper.appSettings("source_id")); ;
                hotel_info.h_id = Guid.NewGuid().ToString();
                hotel_info.h_state = true;
                hotel_info.h_utime = DateTime.Now;
                hotel_info.CheckState = 2;
                hotel_info.h_ctime = DateTime.Now;
                hotel_info.decorateTime = hotel_info.decorateTime == Convert.ToDateTime("0001/1/1 0:00:00") || hotel_info.decorateTime ==null? Convert.ToDateTime("1900-01") : hotel_info.decorateTime;
                hotel_info.h_opening_time = hotel_info.h_opening_time == Convert.ToDateTime("0001/1/1 0:00:00") ? Convert.ToDateTime("1900-01") : hotel_info.h_opening_time;
                //hotel_info.h_room_count = hotel_info.h_room_count == 0 ? 1 : hotel_info.h_room_count;
                hotel_info.u_id = hotel_info.h_mobile_phone;
                using(db=new HotelDBContent())
                {
                   if (hotel_info.hotel_id > 0)
                   {
                       db.Entry(hotel_info).State = EntityState.Modified;
                       
                    
                   }
                   else
                   {

                       var errors = ModelState.Values.SelectMany(v => v.Errors);
                       //if (ModelState.IsValid)
                       //{
                           db.hotel.Add(hotel_info);
                          // result = db.SaveChanges() > 0 ? 1 : 0;
                        
                           var f = (from h in db.hotel where h.h_name_cn == hotel_info.h_name_cn && h.source_id == 4 select h).FirstOrDefault(); 
                           if (f != null)
                               f.h_state = false; //把对应艺龙的酒店干掉
                             
                           // return RedirectToAction("Room/Create/"+ddh.hotel_id);
                       //}
                   }
                   result = db.SaveChanges() > 0 ? 1 : 0;
                   if (result > 0)
                   {
                       var ddh = db.hotel.Select(h => new { h.hotel_id, h.h_id }).Single(h => h.h_id == hotel_info.h_id);
                       return RedirectToAction("room", "AddHotel", new { hotelId = ddh.hotel_id });
                   }

                }    


            }
         
            catch (Exception e)
            {
                throw e;
                help.DBhelp.log("新建公寓基本信息"+e.ToString());
             
            }
            ViewBag.sign = result; getHelpData();
            return View("Create", hotel_info);
        }
Esempio n. 2
0
        public ActionResult Create(GuaranteeRule guaranteerule)
        {

            setName();
            using (db = new HotelDBContent())
            {
                if (guaranteerule.id > 0)
                {

                    db.Entry(guaranteerule).State = EntityState.Modified;
                }
                else
                {
                    Hotel_room_RP_info ratePlan = new Hotel_room_RP_info();
                    ratePlan.hotel_id = guaranteerule.hotel_id;
                    ratePlan.h_room_rp_name_cn = "标准价";
                    int ratePlanId = help.HotelInfoHelp.getRatePlanId(ratePlan);
                    // var rp=(from r in db.rps where r.hotel_id==guaranteerule.hotel_id && r.h_room_rp_state==true && r.h_room_rp_name_cn=="标准价"select r.h_room_rp_id).SingleOrDefault();

                    guaranteerule.h_room_rp_id = ratePlanId;
                    if (ModelState.IsValid)
                    {
                        db.gu.Add(guaranteerule);


                    }
                    db.SaveChanges();
                }
               
            }
            GetData(guaranteerule.hotel_id.ToString());
          
            return View("MyGuarantee", new GuaranteeRule() { GuaranteeType = "FirstNightCost",ChangeRule=1 });
        }