Esempio n. 1
0
        public ActionResult Add(HotelDto hotel)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_SUCCESS,
                Message = SystemConst.MSG_ERR_UNKNOWN
            };

            using (var db = new TravelEntities())
            {
                T_LiveProjects selectedHotel = new T_LiveProjects
                {
                    HouseName   = hotel.HouseName,
                    Fee         = hotel.Fee,
                    SupplierID  = hotel.SupplierID,
                    AgentFee    = hotel.AgentFee,
                    Pics        = hotel.Pics,
                    CoverPic    = hotel.CoverPic,
                    Description = hotel.Description,
                    Remark      = hotel.Remark,
                    Location    = hotel.Location,
                    RoomCount   = hotel.RoomCount
                };
                db.T_LiveProjects.Add(selectedHotel);
                db.SaveChanges();
            }

            return(Content(AppUtils.JsonSerializer(result)));
        }
Esempio n. 2
0
        public ActionResult Modify(HotelDto hotel)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_SUCCESS,
                Message = SystemConst.MSG_ERR_UNKNOWN
            };

            using (var db = new TravelEntities())
            {
                T_LiveProjects selectedHotel = db.T_LiveProjects.FirstOrDefault(a => a.HouseID == hotel.HouseID);
                selectedHotel.HouseName   = hotel.HouseName;
                selectedHotel.Fee         = hotel.Fee;
                selectedHotel.AgentFee    = hotel.AgentFee;
                selectedHotel.CoverPic    = hotel.CoverPic;
                selectedHotel.Description = hotel.Description;
                selectedHotel.Remark      = hotel.Remark;
                selectedHotel.Pics        = hotel.Pics;
                selectedHotel.Location    = hotel.Location;
                selectedHotel.RoomCount   = hotel.RoomCount;
                db.T_LiveProjects.Attach(selectedHotel);
                db.Entry(selectedHotel).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(Content(AppUtils.JsonSerializer(result)));
        }
Esempio n. 3
0
        public ActionResult Add(SupplierPara param)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = String.Empty
            };

            try
            {
                using (var db = new TravelEntities())
                {
                    var supplier = new T_Suppliers
                    {
                        SupplierName = param.supplier.SupplierName,
                        Contact      = param.supplier.Contact,
                        HasHotel     = SystemConst.TRUE,
                        HasService   = SystemConst.TRUE
                    };
                    db.T_Suppliers.Add(supplier);
                    db.SaveChanges();

                    bool needSave = false;
                    if (param.travelProjects != null)
                    {
                        for (var i = 0; i < param.travelProjects.Count; i++)
                        {
                            TravelProjectDto travelProjectDto = param.travelProjects[i];
                            var travelProject = new T_TravelProjects
                            {
                                ProjectName   = travelProjectDto.ProjectName,
                                AdultFee      = travelProjectDto.AdultFee,
                                ChildFee      = travelProjectDto.ChildFee,
                                SupplierID    = supplier.SupplierID,
                                AgentAdultFee = travelProjectDto.AgentAdultFee,
                                AgentChildFee = travelProjectDto.AgentChildFee,
                                CoverPic      = travelProjectDto.CoverPic,
                                Remark        = travelProjectDto.Remark,
                                Description   = travelProjectDto.Description,
                                ProjectTypeID = travelProjectDto.ProjectTypeID
                            };
                            db.T_TravelProjects.Add(travelProject);
                            needSave = true;
                        }
                    }

                    if (param.hotels != null)
                    {
                        for (var i = 0; i < param.hotels.Count; i++)
                        {
                            HotelDto hotelDto = param.hotels[i];
                            var      hotel    = new T_LiveProjects
                            {
                                HouseName   = hotelDto.HouseName,
                                Fee         = hotelDto.Fee,
                                SupplierID  = supplier.SupplierID,
                                AgentFee    = hotelDto.AgentFee,
                                CoverPic    = hotelDto.CoverPic,
                                Description = hotelDto.Description,
                                Remark      = hotelDto.Remark,
                                Pics        = hotelDto.Pics,
                                Location    = hotelDto.Location,
                                RoomCount   = hotelDto.RoomCount
                            };
                            db.T_LiveProjects.Add(hotel);
                            needSave = true;
                        }
                    }

                    if (needSave)
                    {
                        db.SaveChanges();
                    }

                    result.Code = SystemConst.MSG_SUCCESS;
                    return(Content(AppUtils.JsonSerializer(result)));
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }