コード例 #1
0
        private GuideDTO ToDTO(Guide r)
        {
            GuideDTO dto = new GuideDTO();

            dto.CreateDateTime = r.CreateDateTime;
            dto.Id             = r.Id;
            dto.intro          = r.intro;
            dto.isappointment  = r.isappointment;
            dto.level          = r.level;
            dto.shenhe         = r.shenhe;
            dto.picture        = r.picture;
            dto.school         = r.school;
            dto.schoolnum      = r.schoolnum;
            dto.jifen          = r.jifen;
            dto.school         = r.school;
            using (Dbcontext ctx = new Dbcontext())
            {
                BaseService <User> bs = new BaseService <User>(ctx);
                var user = bs.GetById(r.Users_Id);
                if (user != null)
                {
                    dto.nickname = user.NickName;
                }
            }
            dto.Users_Id = r.Users_Id;
            //using (Dbcontext ctx = new Dbcontext())
            //{
            //    BaseService<User> bs = new BaseService<User>(ctx);
            //    var Guide_UserInfo = bs.GetAll().Where(e => e.Id == r.Users_Id).FirstOrDefault();
            //    // dto.NickName = Guide_UserInfo.NickName;
            //}
            return(dto);
        }
コード例 #2
0
ファイル: GuideController.cs プロジェクト: Y7-11/bysj
        public ActionResult ToBeGuide()
        {
            GuideDTO           model     = new GuideDTO();
            string             school    = Request["schoolname"];
            string             schoolnum = Request["schoolnum"];
            string             intro     = Request["intro"];
            HttpPostedFileBase file      = Request.Files["upfile"];

            model.intro  = intro;
            model.school = school;
            if (file.ContentLength > 0)
            {
                file.SaveAs(Server.MapPath("~/images/head/") + System.IO.Path.GetFileName(file.FileName));
            }
            model.picture = "/images/head/" + System.IO.Path.GetFileName(file.FileName);

            long id = new GuideService().AddGuide((long)Session["LoginUserId"], school, schoolnum, model.picture, intro);

            long[] role = new long[1];
            role[0] = 6;
            new UserRoleService().AddUserRole((long)Session["LoginUserId"], role);
            if (new GuideUserService().AddGuideUser((long)Session["LoginUserId"], id) > 0)
            {
                return(Redirect("/Main/Index"));
            }
            else
            {
                return(Content("<script>alert('注册失败');history.go(-1);</script>"));
            }
        }
コード例 #3
0
        public string GuideGetAllByBookingId(int restaurantBookingId)
        {
            var listGuide    = BookingViewingBLL.GuideGetAllByBookingId(restaurantBookingId);
            var listGuideDTO = new List <GuideDTO>();

            foreach (var guide in listGuide)
            {
                var guideDTO = new GuideDTO()
                {
                    id    = guide.Id,
                    name  = guide.Name,
                    phone = guide.Phone,
                    restaurantBookingId = guide.RestaurantBooking.Id,
                };
                listGuideDTO.Add(guideDTO);
            }
            Dispose();
            return(JsonConvert.SerializeObject(listGuideDTO));
        }
コード例 #4
0
        public string TransferRequestDTOGetByCriterion(string d, string bti, string ri)
        {
            DateTime?date = null;

            try
            {
                date = DateTime.ParseExact(d, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch { }
            var busTypeId = -1;

            try
            {
                busTypeId = Int32.Parse(bti);
            }
            catch { }
            var listBusType = TransferRequestByDateBLL.BusTypeGetAllById(busTypeId).Future().ToList();
            var routeId     = -1;

            try
            {
                routeId = Int32.Parse(ri);
            }
            catch { }
            var listRoute    = TransferRequestByDateBLL.RouteGetAllById(routeId).Future().ToList();
            var listRouteDTO = new List <RouteDTO>();

            foreach (var route in listRoute)
            {
                var listBusTypeDTO = new List <BusTypeDTO>();
                var routeDTO       = new RouteDTO()
                {
                    Id   = route.Id,
                    Name = route.Name,
                    Way  = route.Way,
                };
                foreach (var busType in listBusType)
                {
                    var busTypeDTO = new BusTypeDTO()
                    {
                        Id   = busType.Id,
                        Name = busType.Name,
                        HaveBookingNoGroup = BusTypeCheckBookingHaveNoGroup(busType, route, date),
                        HaveNoBooking      = false,
                    };
                    var listBusByDateDTO = new List <BusByDateDTO>();
                    var listBusByDate    = TransferRequestByDateBLL.BusByDateGetAllByCriterion(date, busType, route, route.Way)
                                           .OrderBy(y => y.Group).Asc.Future().ToList();
                    listBusByDate.ForEach(busByDate =>
                    {
                        var listBookingBusByDate = TransferRequestByDateBLL.BookingBusByDateGetAllByCriterion(busByDate).Future().ToList();
                        var listBooking          = listBookingBusByDate.Select(x => x.Booking).Distinct().ToList();
                        int?supplierId           = null;
                        if (busByDate.Supplier != null)
                        {
                            supplierId = busByDate.Supplier.Id;
                        }
                        var busByDateDTO = new BusByDateDTO()
                        {
                            Id           = busByDate.Id,
                            Group        = busByDate.Group,
                            Driver_Name  = busByDate.Driver_Name,
                            Driver_Phone = busByDate.Driver_Phone,
                            Adult        = listBooking.Select(x => x.Adult).Sum(),
                            Child        = listBooking.Select(x => x.Child).Sum(),
                            Baby         = listBooking.Select(x => x.Baby).Sum(),
                            SupplierId   = supplierId,
                            RouteName    = busByDate.Route != null ? busByDate.Route.Name : "",
                            BusTypeName  = busByDate.BusType != null ? busByDate.BusType.Name : "",
                        };
                        foreach (var busByDateGuide in busByDate.BusByDatesGuides)
                        {
                            var guide         = busByDateGuide.Guide;
                            GuideDTO guideDTO = null;
                            if (guide != null && guide.Id > 0)
                            {
                                guideDTO = new GuideDTO()
                                {
                                    Id    = guide.Id,
                                    Name  = guide.Name,
                                    Phone = guide.Phone,
                                };
                            }
                            var busByDateGuideDTO = new BusByDateGuideDTO()
                            {
                                BusByDateDTO = busByDateDTO,
                                GuideDTO     = guideDTO
                            };
                            busByDateDTO.BusByDatesGuidesDTO.Add(busByDateGuideDTO);
                        }
                        listBusByDateDTO.Add(busByDateDTO);
                    });
                    busTypeDTO.ListBusByDateDTO = listBusByDateDTO;
                    listBusTypeDTO.Add(busTypeDTO);
                }
                routeDTO.ListBusTypeDTO = listBusTypeDTO;
                listRouteDTO.Add(routeDTO);
            }
            var transferRequestDTO = new TransferRequestDTO();

            transferRequestDTO.ListRouteDTO = listRouteDTO;
            Dispose();
            return(JsonConvert.SerializeObject(transferRequestDTO));
        }