예제 #1
0
        public ActionResult ModifyVipService(VIPDto vip)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_VIPs theVIP = db.T_VIPs.FirstOrDefault(a => a.ServerID == vip.ServerID);
                    theVIP.ServerName = vip.ServerName;
                    theVIP.Contact    = vip.Contact;
                    theVIP.Tel        = vip.Tel;
                    theVIP.Remark     = vip.Remark;
                    theVIP.SupplierID = vip.SupplierID;
                    db.T_VIPs.Attach(theVIP);
                    db.Entry(theVIP).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }
예제 #2
0
        public ActionResult ModifyUser(UserDto user)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_Users theUser = db.T_Users.FirstOrDefault(a => a.UserID == user.UserID);
                    theUser.UserName  = user.UserName;
                    theUser.LoginName = user.LoginName;
                    theUser.RoleID    = user.RoleID;
                    theUser.Status    = user.isEnable ? SystemConst.ENABLE : SystemConst.DISABLE;
                    db.T_Users.Attach(theUser);
                    db.Entry(theUser).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }
예제 #3
0
        public ActionResult GetAll()
        {
            var db        = new TravelEntities();
            var customers = db.T_Customers.ToList();

            return(Content(AppUtils.JsonSerializer(customers)));
        }
예제 #4
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)));
        }
예제 #5
0
        public ActionResult ModifyGuide(GuideDto guide)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_Guides theGuide = db.T_Guides.FirstOrDefault(a => a.GuideID == guide.GuideID);
                    theGuide.Tel          = guide.Tel;
                    theGuide.Contact      = guide.Contact;
                    theGuide.LandFee      = guide.LandFee;
                    theGuide.SeaFee       = guide.SeaFee;
                    theGuide.AgentLandFee = guide.AgentLandFee;
                    theGuide.AgentSeaFee  = guide.AgentSeaFee;
                    theGuide.Remark       = guide.Remark;
                    theGuide.SupplierID   = guide.SupplierID;
                    db.T_Guides.Attach(theGuide);
                    db.Entry(theGuide).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }
예제 #6
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)));
        }
예제 #7
0
        public ActionResult AddNewVipService(VIPDto vip)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_VIPs newVip = new T_VIPs
                    {
                        ServerName = vip.ServerName,
                        Tel        = vip.Tel,
                        SupplierID = vip.SupplierID,
                        Contact    = vip.Contact,
                        Remark     = vip.Remark
                    };
                    db.T_VIPs.Add(newVip);
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }
예제 #8
0
        // GET: Vip
        public ActionResult GetAll(int?supplierID)
        {
            var           db = new TravelEntities();
            List <VIPDto> vipServices;

            if (supplierID != null)
            {
                vipServices = vipServices = (from vip in db.T_VIPs
                                             select new VIPDto
                {
                    ServerID = vip.ServerID,
                    ServerName = vip.ServerName,
                    Contact = vip.Contact,
                    Tel = vip.Tel,
                    Remark = vip.Remark,
                    SupplierID = vip.SupplierID
                }).Where(a => a.SupplierID == supplierID).ToList();
            }
            else
            {
                vipServices = vipServices = (from vip in db.T_VIPs
                                             select new VIPDto
                {
                    ServerID = vip.ServerID,
                    ServerName = vip.ServerName,
                    Contact = vip.Contact,
                    Tel = vip.Tel,
                    Remark = vip.Remark,
                    SupplierID = vip.SupplierID
                }).ToList();
            }
            return(Content(AppUtils.JsonSerializer(vipServices)));
        }
예제 #9
0
        public ActionResult AddNewGuide(GuideDto newGuide)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_Guides guide = new T_Guides
                    {
                        GuideName    = newGuide.GuideName,
                        Tel          = newGuide.Tel,
                        Contact      = newGuide.Contact,
                        LandFee      = newGuide.LandFee,
                        AgentLandFee = newGuide.AgentLandFee,
                        SeaFee       = newGuide.SeaFee,
                        AgentSeaFee  = newGuide.AgentSeaFee,
                        Remark       = newGuide.Remark,
                        SupplierID   = newGuide.SupplierID
                    };
                    db.T_Guides.Add(guide);
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }
예제 #10
0
 internal static void AddProject(int tripID, int seq, string start, string end, string projectID)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         if (detail == null)
         {
             return;
         }
         string[]      id_type       = projectID.Split(':');
         DetailProject detailProject = new DetailProject
         {
             Start     = start,
             End       = end,
             ProjectID = Convert.ToInt16(id_type[0]),
             TypeID    = Convert.ToInt16(id_type[1]),
         };
         List <DetailProject> detailProjects;
         if (detail.ProjectList == null || detail.ProjectList.Equals(string.Empty))
         {
             detailProjects = new List <DetailProject>();
         }
         else
         {
             detailProjects = Common.AppUtils.JsonDeserialize <List <DetailProject> >(detail.ProjectList);
         }
         detailProjects.Add(detailProject);
         detail.ProjectList = Common.AppUtils.JsonSerializer(detailProjects);
         detail.Description = detail.Description;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #11
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // 这不会计入到为执行帐户锁定而统计的登录失败次数中
            // 若要在多次输入错误密码的情况下触发帐户锁定,请更改为 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, false, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                using (var db = new TravelEntities())
                {
                    T_Users user = db.T_Users.Where(a => a.LoginName.Equals(model.UserName)).FirstOrDefault();
                    if (user != null)
                    {
                        Session["UserId"]   = user.UserID;
                        Session["UserName"] = user.UserName;
                    }
                }
                AuthenticationManager.SignIn(new AuthenticationProperties(), new ClaimsIdentity());
                return(RedirectToLocal(returnUrl));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "无效的登录尝试。");
                return(View(model));
            }
        }
예제 #12
0
 public static void AddTrip(string trip_name, int trip_price,
                            string customer_name, int trip_days,
                            string trip_date, string custom_require,
                            string remark, int customer_count)
 {
     using (var db = new TravelEntities())
     {
         T_Schedule schedule = new T_Schedule
         {
             ScheduleName  = trip_name,
             Fee           = trip_price,
             CustomerName  = customer_name,
             CustomRequire = custom_require,
             CustomerCount = customer_count,
             Days          = trip_days,
             VisitDate     = (trip_date == null || trip_date.Equals(string.Empty))?DateTime.Today: Convert.ToDateTime(trip_date),
             Remark        = remark,
             AgentID       = Convert.ToInt16(HttpContext.Current.Session["UserId"]),
             Status        = SystemConst.TRIP_STATUS_NEW
         };
         db.T_Schedule.Add(schedule);
         db.SaveChanges();
         int tripID = schedule.ScheduleID;
         for (int i = 1; i <= trip_days; i++)
         {
             AddEmptyDay(db, tripID, i);
             db.SaveChanges();
         }
     }
 }
        public ActionResult Add(TravelProjectDto travelProject)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_SUCCESS,
                Message = SystemConst.MSG_ERR_UNKNOWN
            };

            using (var db = new TravelEntities())
            {
                T_TravelProjects selectTravelProject = new T_TravelProjects
                {
                    ProjectName   = travelProject.ProjectName,
                    AdultFee      = travelProject.AdultFee,
                    ChildFee      = travelProject.ChildFee,
                    SupplierID    = travelProject.SupplierID,
                    AgentAdultFee = travelProject.AgentAdultFee,
                    AgentChildFee = travelProject.AgentChildFee,
                    Description   = travelProject.Description,
                    ProjectTypeID = travelProject.ProjectTypeID,
                    Remark        = travelProject.Remark,
                    CoverPic      = travelProject.CoverPic
                };
                db.T_TravelProjects.Add(selectTravelProject);
                db.SaveChanges();
            }

            return(Content(AppUtils.JsonSerializer(result)));
        }
        public ActionResult Modify(TravelProjectDto travelProject)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_SUCCESS,
                Message = SystemConst.MSG_ERR_UNKNOWN
            };

            using (var db = new TravelEntities())
            {
                T_TravelProjects selectTravelProject = db.T_TravelProjects.FirstOrDefault(a => a.ProjectID == travelProject.ProjectID);
                selectTravelProject.ProjectName   = travelProject.ProjectName;
                selectTravelProject.AdultFee      = travelProject.AdultFee;
                selectTravelProject.ChildFee      = travelProject.ChildFee;
                selectTravelProject.AgentAdultFee = travelProject.AgentAdultFee;
                selectTravelProject.AgentChildFee = travelProject.AgentChildFee;
                selectTravelProject.Description   = travelProject.Description;
                selectTravelProject.ProjectTypeID = travelProject.ProjectTypeID;
                selectTravelProject.Remark        = travelProject.Remark;
                selectTravelProject.CoverPic      = travelProject.CoverPic;
                db.T_TravelProjects.Attach(selectTravelProject);
                db.Entry(selectTravelProject).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(Content(AppUtils.JsonSerializer(result)));
        }
예제 #15
0
 internal static void DeleteProject(int tripID, int seq, int projectSeq)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         if (detail == null)
         {
             return;
         }
         List <DetailProject> detailProjects;
         if (detail.ProjectList == null || detail.ProjectList.Equals(string.Empty))
         {
             return;
         }
         else
         {
             detailProjects = Common.AppUtils.JsonDeserialize <List <DetailProject> >(detail.ProjectList);
         }
         if (detailProjects.Count < projectSeq)
         {
             return;
         }
         detailProjects.RemoveAt(projectSeq);
         detail.ProjectList = Common.AppUtils.JsonSerializer(detailProjects);
         detail.Description = detail.Description;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public ActionResult GetAllProjectTypes()
 {
     using (var db = new TravelEntities())
     {
         var projectTypes = db.T_TravelProjectTypes.ToList();
         return(Content(AppUtils.JsonSerializer(projectTypes)));
     }
 }
예제 #17
0
        public ActionResult GetSupplierInfo(int supplierID)
        {
            SupplierResult result = new SupplierResult()
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = String.Empty
            };

            try
            {
                SupplierPara supplierInfo = new SupplierPara();
                using (var db = new TravelEntities())
                {
                    supplierInfo.travelProjects = (from travelProject in db.T_TravelProjects
                                                   join projectType in db.T_TravelProjectTypes on travelProject.ProjectTypeID equals projectType.ProjectTypeID into temp
                                                   from i in temp.DefaultIfEmpty()
                                                   where travelProject.SupplierID == supplierID
                                                   select new TravelProjectDto
                    {
                        ProjectID = travelProject.ProjectID,
                        ProjectName = travelProject.ProjectName,
                        AdultFee = travelProject.AdultFee,
                        ChildFee = travelProject.ChildFee,
                        AgentAdultFee = travelProject.AgentAdultFee,
                        AgentChildFee = travelProject.AgentChildFee,
                        ProjectTypeID = travelProject.ProjectTypeID,
                        ProjectTypeName = i.ProjectTypeName,
                        Remark = travelProject.Remark,
                        Description = travelProject.Description,
                        CoverPic = travelProject.CoverPic,
                        SupplierID = travelProject.SupplierID
                    }).ToList();
                    supplierInfo.hotels = (from hotel in db.T_LiveProjects.Where(a => a.SupplierID == supplierID)
                                           select new HotelDto
                    {
                        HouseID = hotel.HouseID,
                        HouseName = hotel.HouseName,
                        Fee = hotel.Fee,
                        SupplierID = hotel.SupplierID,
                        AgentFee = hotel.AgentFee,
                        CoverPic = hotel.CoverPic,
                        Description = hotel.Description,
                        Remark = hotel.Remark,
                        Pics = hotel.Pics,
                        Location = hotel.Location,
                        RoomCount = hotel.RoomCount
                    }).ToList();
                }
                result.Code = SystemConst.MSG_SUCCESS;
                result.Data = supplierInfo;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Content(AppUtils.JsonSerializer(result)));
        }
예제 #18
0
 public static void AddNewDay(int tripID)
 {
     using (var db = new TravelEntities())
     {
         var seq = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID).Select(q => q.Seq).DefaultIfEmpty();
         AddEmptyDay(db, tripID, seq.Max() + 1);
         db.SaveChanges();
     }
 }
예제 #19
0
        public ActionResult GetAll(int?supplierID)
        {
            var db = new TravelEntities();
            List <DriverDto> drivers;

            if (supplierID != null)
            {
                drivers = (from driver in db.T_Drivers
                           select new DriverDto
                {
                    DriverID = driver.DriverID,
                    DriverName = driver.DriverName,
                    Tel = driver.Tel,
                    Contact = driver.Contact,
                    BigCarFee = driver.BigCarFee,
                    SmallCarFee = driver.SmallCarFee,
                    BigCarPickAirportFee = driver.BigCarPickAirportFee,
                    SmallCarPickAirportFee = driver.SmallCarPickAirportFee,
                    BigCarSendAirportFee = driver.BigCarSendAirportFee,
                    SmallCarSendAirportFee = driver.SmallCarSendAirportFee,
                    AgentBigCarFee = driver.AgentBigCarFee,
                    AgentSmallCarFee = driver.AgentSmallCarFee,
                    AgentBigCarPickAirportFee = driver.AgentBigCarPickAirportFee,
                    AgentSmallCarPickAirportFee = driver.AgentSmallCarPickAirportFee,
                    AgentBigCarSendAirportFee = driver.AgentBigCarSendAirportFee,
                    AgentSmallCarSendAirportFee = driver.AgentSmallCarSendAirportFee,
                    Remark = driver.Remark,
                    SupplierID = driver.SupplierID
                }).Where(a => a.SupplierID == supplierID).ToList();
            }
            else
            {
                drivers = (from driver in db.T_Drivers
                           select new DriverDto
                {
                    DriverID = driver.DriverID,
                    DriverName = driver.DriverName,
                    Tel = driver.Tel,
                    Contact = driver.Contact,
                    BigCarFee = driver.BigCarFee,
                    SmallCarFee = driver.SmallCarFee,
                    BigCarPickAirportFee = driver.BigCarPickAirportFee,
                    SmallCarPickAirportFee = driver.SmallCarPickAirportFee,
                    BigCarSendAirportFee = driver.BigCarSendAirportFee,
                    SmallCarSendAirportFee = driver.SmallCarSendAirportFee,
                    AgentBigCarFee = driver.AgentBigCarFee,
                    AgentSmallCarFee = driver.AgentSmallCarFee,
                    AgentBigCarPickAirportFee = driver.AgentBigCarPickAirportFee,
                    AgentSmallCarPickAirportFee = driver.AgentSmallCarPickAirportFee,
                    AgentBigCarSendAirportFee = driver.AgentBigCarSendAirportFee,
                    AgentSmallCarSendAirportFee = driver.AgentSmallCarSendAirportFee,
                    Remark = driver.Remark,
                    SupplierID = driver.SupplierID
                }).ToList();
            }
            return(Content(AppUtils.JsonSerializer(drivers)));
        }
예제 #20
0
        public ActionResult Login(LoginPara para)
        {
            LoginResult result = new LoginResult()
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = String.Empty
            };

            using (var db = new TravelEntities())
            {
                var users = db.T_Users.Count();
                if (users == 0 && para.Username.Equals(SYS_ADMIN_NAME) && para.Password.Equals(AppUtils.SHA1Hash(SYS_PASSWORD)))
                {
                    result.Code = SystemConst.MSG_SUCCESS;
                    LoginDto loginResult = new LoginDto
                    {
                        UserID    = SystemConst.SYS_ADMIN,
                        UserName  = String.Empty,
                        Functions = new List <string>(),
                    };
                    result.Data = loginResult;
                    return(Content(AppUtils.JsonSerializer(result)));
                }

                var user =
                    db.T_Users.Where(a => a.LoginName == para.Username && a.Status.Equals(SystemConst.ENABLE))
                    .FirstOrDefault();
                if (user != null && para.Password.Equals(user.Password))
                {
                    var fx = (from roleFunction in db.T_RoleFunction
                              join function in db.T_Functions on roleFunction.FunctionID equals function.ID
                              where roleFunction.RoleID == user.RoleID
                              select function).ToList();

                    List <String> selectfunction = new List <string>();
                    foreach (var function in fx)
                    {
                        selectfunction.Add(function.Code.ToString());
                    }

                    LoginDto loginResult = new LoginDto
                    {
                        UserID    = user.UserID,
                        UserName  = user.UserName,
                        Functions = selectfunction,
                    };
                    result.Data = loginResult;
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                else
                {
                    result.Message = "ERROR_PASSWORD";
                }
            }
            return(Content(AppUtils.JsonSerializer(result)));
        }
예제 #21
0
        private static void AddEmptyDay(TravelEntities db, int tripID, int i)
        {
            T_ScheduleDetail detail = new T_ScheduleDetail();

            detail.ScheduleID  = tripID;
            detail.Seq         = i;
            detail.ProjectList = string.Empty;
            detail.Description = string.Empty;
            db.T_ScheduleDetail.Add(detail);
        }
예제 #22
0
 internal static void EditDayDesc(int tripID, int seq, string desc)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         detail.Description = desc;
         detail.ProjectList = detail.ProjectList;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #23
0
 internal static void DeleteDay(int tripID, int seq)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = new T_ScheduleDetail()
         {
             ScheduleID = tripID, Seq = seq
         };
         db.T_ScheduleDetail.Attach(detail);
         db.T_ScheduleDetail.Remove(detail);
         db.SaveChanges();
     }
 }
예제 #24
0
 // GET: Supplier
 public ActionResult Get()
 {
     using (var db = new TravelEntities())
     {
         var result = (from supplier in db.T_Suppliers
                       select new Supplier
         {
             SupplierID = supplier.SupplierID,
             SupplierName = supplier.SupplierName,
             Contact = supplier.Contact
         }).ToList();
         return(Content(AppUtils.JsonSerializer(result)));
     }
 }
예제 #25
0
 public virtual async Task <SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout)
 {
     using (var db = new TravelEntities())
     {
         T_Users user = db.T_Users.Where(a => a.LoginName.Equals(userName)).FirstOrDefault();
         if (user != null && user.Password.Equals(AppUtils.SHA1Hash(password)))
         {
             return(SignInStatus.Success);
         }
         else
         {
             return(SignInStatus.Failure);
         }
     }
 }
예제 #26
0
 public static ServiceDetailViewModel GetServiceDetail(int?serviceID, int?typeID)
 {
     using (var db = new TravelEntities())
     {
         if (typeID == WebConst.HOTEL_TYPE)
         {
             var hotel = (from service in db.T_LiveProjects
                          join supplier in db.T_Suppliers on service.SupplierID equals supplier.SupplierID into temp
                          from i in temp.DefaultIfEmpty()
                          where service.HouseID == serviceID
                          select new ServiceDetailViewModel
             {
                 ServiceID = service.HouseID,
                 ServiceName = service.HouseName,
                 ProjectTypeName = WebConst.HOTEL_TYPE_NAME,
                 AgentAdultFee = service.AgentFee,
                 CoverPic = service.CoverPic,
                 Pics = service.Pics,
                 SupplierName = i.SupplierName,
                 Description = service.Description,
                 Remark = service.Remark,
             }).FirstOrDefault();
             return(hotel);
         }
         else
         {
             var project = (from service in db.T_TravelProjects
                            join supplier in db.T_Suppliers on service.SupplierID equals supplier.SupplierID into temp
                            from i in temp.DefaultIfEmpty()
                            join travelType in db.T_TravelProjectTypes on service.ProjectTypeID equals travelType.ProjectTypeID into projectTypes
                            from projectType in projectTypes.DefaultIfEmpty()
                            where service.ProjectID == serviceID && service.ProjectTypeID == typeID
                            select new ServiceDetailViewModel
             {
                 ServiceID = service.ProjectID,
                 ServiceName = service.ProjectName,
                 ProjectTypeName = projectType.ProjectTypeName,
                 AgentAdultFee = service.AgentAdultFee,
                 AgentChildFee = service.AgentChildFee,
                 SupplierName = i.SupplierName,
                 CoverPic = service.CoverPic,
                 Description = service.Description,
                 Remark = service.Remark
             }).FirstOrDefault();
             return(project);
         }
     }
 }
예제 #27
0
 public static IList <T_TravelProjectTypes> GetAllServiceTypes()
 {
     using (var db = new TravelEntities())
     {
         var types = db.T_TravelProjectTypes.ToList();
         T_TravelProjectTypes allType = new T_TravelProjectTypes();
         allType.ProjectTypeID   = WebConst.ALL_TYPE;
         allType.ProjectTypeName = WebConst.ALL_TYPE_NAME;
         types.Insert(0, allType);
         T_TravelProjectTypes hotelType = new T_TravelProjectTypes();
         hotelType.ProjectTypeID   = WebConst.HOTEL_TYPE;
         hotelType.ProjectTypeName = WebConst.HOTEL_TYPE_NAME;
         types.Add(hotelType);
         return(types);
     }
 }
예제 #28
0
 public ActionResult InitProjectTypes()
 {
     using (var db = new TravelEntities())
     {
         String[] types       = { "车辆接送", "一日游", "门票", "潜水", "SPA按摩", "包船" };
         var      originTypes = db.T_TravelProjectTypes.ToList();
         db.T_TravelProjectTypes.RemoveRange(originTypes);
         foreach (String typeName in types)
         {
             T_TravelProjectTypes newType = new T_TravelProjectTypes();
             newType.ProjectTypeName = typeName;
             db.T_TravelProjectTypes.Add(newType);
         }
         db.SaveChanges();
         return(Content("初始化完成"));
     }
 }
예제 #29
0
 public static void AddNewDay(int tripID, string services, string desc)
 {
     if (services.Equals(string.Empty))
     {
         return;
     }
     using (var db = new TravelEntities())
     {
         var seq = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID).Select(q => q.Seq).DefaultIfEmpty();
         T_ScheduleDetail detail = new T_ScheduleDetail();
         detail.ScheduleID  = tripID;
         detail.Seq         = seq.Max() + 1;
         detail.ProjectList = services.Remove(services.Length - 1);
         detail.Description = desc;
         db.T_ScheduleDetail.Add(detail);
         db.SaveChanges();
     }
 }
예제 #30
0
        public ActionResult AddNewDriver(DriverDto newDriver)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = string.Empty
            };

            using (var db = new TravelEntities())
            {
                try
                {
                    T_Drivers driver = new T_Drivers
                    {
                        DriverName                  = newDriver.DriverName,
                        Tel                         = newDriver.Tel,
                        Contact                     = newDriver.Contact,
                        BigCarFee                   = newDriver.BigCarFee,
                        SmallCarFee                 = newDriver.SmallCarFee,
                        BigCarPickAirportFee        = newDriver.BigCarPickAirportFee,
                        SmallCarPickAirportFee      = newDriver.SmallCarPickAirportFee,
                        BigCarSendAirportFee        = newDriver.BigCarSendAirportFee,
                        SmallCarSendAirportFee      = newDriver.SmallCarSendAirportFee,
                        AgentBigCarFee              = newDriver.AgentBigCarFee,
                        AgentSmallCarFee            = newDriver.AgentSmallCarFee,
                        AgentBigCarPickAirportFee   = newDriver.AgentBigCarPickAirportFee,
                        AgentSmallCarPickAirportFee = newDriver.AgentSmallCarPickAirportFee,
                        AgentBigCarSendAirportFee   = newDriver.AgentBigCarSendAirportFee,
                        AgentSmallCarSendAirportFee = newDriver.AgentSmallCarSendAirportFee,
                        Remark                      = newDriver.Remark,
                        SupplierID                  = newDriver.SupplierID
                    };
                    db.T_Drivers.Add(driver);
                    db.SaveChanges();
                    result.Code = SystemConst.MSG_SUCCESS;
                }
                catch (Exception exception)
                {
                    result.Message = exception.Message;
                }
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }