Example #1
0
        public OperationResult CopyToCustomer(ExternalLoginConfirmationViewModel model)
        {
            OperationResult copyResult = new OperationResult();

            try
            {
                AppleLaLaModel context = new AppleLaLaModel();
                AppleLaLaRepository <Customer> repository = new AppleLaLaRepository <Customer>(context);

                var copyUser = new Customer
                {
                    Name             = model.Name,
                    Account          = model.Email,
                    Birthday         = model.Birthday,
                    Address          = model.Address,
                    Mobile           = model.PhoneNumber,
                    Gender           = model.Sex,
                    Last_updata_date = DateTime.Now,
                };
                repository.Create(copyUser);
                context.SaveChanges();
                copyResult.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                copyResult.IsSuccessful = false;
                copyResult.exception    = ex;
            }
            return(copyResult);
        }
        public List <Choose_services_list_vm> GetData()
        {
            AppleLaLaModel DBContext = new AppleLaLaModel();


            var serviceCollection = (from s in DBContext.Service
                                     join st in DBContext.Service_types on s.Service_id equals st.Service_id
                                     join sd in DBContext.Service_details on st.Type_id equals sd.Type_id
                                     select new Choose_services_list_vm
            {
                Id = s.Service_id,
                Service = s.Service_name,
                ServicePhoto = s.Service_photo_url,
                ServiceTitle = st.Type_name,
                ServiceDetail = sd.Name,
                Service_Detail_id = sd.Service_details_Id,
                WorkDuration = sd.Work_duration,
                Price = sd.Price,
                portfolios = (from sds in DBContext.Service_details
                              join p in DBContext.Protfolio on sds.Service_details_Id equals p.Service_details_Id
                              select new Portfolio
                {
                    Photo = p.Photo_url,
                    ServiceDetailid = p.Service_details_Id
                }).ToList(),
                DiscountPrice = sd.Discount_price
            }).ToList();

            return(serviceCollection);
        }
Example #3
0
        public Choose_services_list_vm GetData()
        {
            //1.初始化資料庫的model
            AppleLaLaModel DBContext = new AppleLaLaModel();

            //2.把AppleLaLaRepository定義為Service的型別 並初始化
            AppleLaLaRepository <Service> service = new AppleLaLaRepository <Service>(DBContext);

            //3.叫用Repository內的GetAll()這個方法,並取得資料
            var serviceData = service.GetAll();

            //4.選取需要的欄位,塞給自己的ViewModel,並存給變數
            //var serviceCollection = serviceData.Select(x => new Choose_services_list_vm { })

            //4. 查詢需要的資料表,取得需要的欄位資料,並存成變數 (多個資料表查詢方式)
            //var serviceCollection = from s in DBContext.Service
            //                        join st in DBContext.Service_types on s.Service_id equals st.Service_id
            //                        join sd in DBContext.Service_details on st.Type_id equals sd.Type_id
            //                        select new Choose_services_list_vm


            ////new自己的ViewModel
            //var i = new Choose_services_list_vm();

            //foreach (var item in repository.GetAll().OrderBy(x => x.Service_id))
            //{
            //    i.Id = item.Service_id;
            //    i.Service = item.Service_name;
            //    i.ServicePhoto = item.Service_photo_url;
            //};
            //return i;
        }
Example #4
0
        public string[] GetLabels()
        {
            AppleLaLaModel context = new AppleLaLaModel();
            var            labels  = context.Service.OrderBy(x => x.Service_id).Select((x) => x.Service_name).ToArray();

            return(labels);
        }
 public AppleLaLaRepository(AppleLaLaModel context)
 {
     if (context == null)
     {
         throw new ArgumentException();
     }
     _context = context;
 }
        public List <AboutusViewModel> per_one()
        {
            AppleLaLaModel context = new AppleLaLaModel();
            AppleLaLaRepository <Designer> designer_Info = new AppleLaLaRepository <Designer>(context);
            var persons             = designer_Info.GetAll();
            var _returnDesignerInfo =
                persons.Select((x) => new AboutusViewModel {
                Id = x.Designer_id, DesignerPicURL = x.Photo_rul, DesignerName = x.Name
            }).ToList();

            return(_returnDesignerInfo);
        }
Example #7
0
        public List <ContactViewModel> ShopInfo()
        {
            AppleLaLaModel             context   = new AppleLaLaModel();
            AppleLaLaRepository <Shop> storeInfo = new AppleLaLaRepository <Shop>(context);
            var shopData        = storeInfo.GetAll();
            var _returnShopData =
                shopData.Select((x) => new ContactViewModel {
                Store = x.Name, Adderss = x.Address, Description = x.Description, Phone = x.Mobile, Photo = x.Photo, Tel = x.Tel
            }).ToList();

            return(_returnShopData);
        }
Example #8
0
        public List <HomeOurServiceViewModel> GetOurServiceData()
        {
            AppleLaLaModel context = new AppleLaLaModel();
            AppleLaLaRepository <Service> service = new AppleLaLaRepository <Service>(context);

            var serviceData = service.GetAll();

            var returnData =
                serviceData.Select((x) => new HomeOurServiceViewModel {
                Service_name = x.Service_name, Description = x.Description, ImgUrl = x.Service_photo_url
            }).ToList();

            return(returnData);
        }
Example #9
0
        public List <HomeEnvironmentViewModel> GetHomeEnvironmentData()
        {
            AppleLaLaModel context = new AppleLaLaModel();
            AppleLaLaRepository <MVCDataLibrary.DB_Model.Environment> Environment = new AppleLaLaRepository <MVCDataLibrary.DB_Model.Environment>(context);

            var EnvironmentData = Environment.GetAll();

            var returnEnvironmentData = EnvironmentData.Select((x) => new HomeEnvironmentViewModel {
                ImgUrl = x.Environment_photo
            }).ToList();


            return(returnEnvironmentData);
        }
Example #10
0
        public Service_list_ViewModel GetService()
        {
            var context = new AppleLaLaModel();
            var data    = (context.Service.Where(r => r.Service_id != 30)
                           .Select(r =>
                                   new ServicesViewModel {
                Service_name = r.Service_name, Service_photo = r.Service_photo_url
            })).Take(3).ToList();

            var result = new Service_list_ViewModel {
                three_Service = data
            };

            return(result);
        }
Example #11
0
        public List <BannerViewModel> GetBannerData()
        {
            AppleLaLaModel homePage = new AppleLaLaModel();
            AppleLaLaRepository <Banner> repository_b = new AppleLaLaRepository <Banner>(homePage);
            List <BannerViewModel>       returnData   = repository_b.GetAll()
                                                        .Select((x) => new BannerViewModel
            {
                Title            = x.Title,
                Sut_title        = x.Sut_title,
                Text             = x.Text,
                Banner_photo_url = x.Banner_photo_url
            }).ToList();

            return(returnData);
        }
        public ActionResult AdminLogin(AdminLoginViewModel loginVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(loginVM));
            }

            //編碼
            string         userName = HttpUtility.HtmlEncode(loginVM.UserName);
            string         password = HashService.MD5Hash(HttpUtility.HtmlEncode(loginVM.Password));
            AppleLaLaModel context  = new AppleLaLaModel();
            Admin_accounts user     = context.Admin_accounts.Where((x) => x.UserName == userName && x.Password == password).FirstOrDefault();

            if (user == null)
            {
                ModelState.AddModelError("", "無效");
                return(View(loginVM));
            }

            TempData["Name"] = user.UserName;

            //登入cookie樣版
            var ticket = new FormsAuthenticationTicket(
                version: 1,
                name: user.UserName.ToString(),             //可以放使用者Id
                issueDate: DateTime.UtcNow,                 //現在UTC時間
                expiration: DateTime.UtcNow.AddMinutes(30), //Cookie有效時間=現在時間往後+30分鐘
                isPersistent: true,                         // 是否要記住我 true or false
                userData: "",                               //可以放使用者角色名稱
                cookiePath: FormsAuthentication.FormsCookiePath);

            // Encrypt the ticket.
            var encryptedTicket = FormsAuthentication.Encrypt(ticket); //把驗證的表單加密

            // Create the cookie.
            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

            Response.Cookies.Add(cookie);

            // Redirect back to original URL.
            var url = FormsAuthentication.GetRedirectUrl(userName, true);

            //return Redirect(FormsAuthentication.GetRedirectUrl(name, true));
            //登入cookie樣版


            return(RedirectToAction("Index", "Home"));
        }
Example #13
0
        public Service_list_ViewModel GetPortfilo()
        {
            var context = new AppleLaLaModel();
            List <ServicesViewModel> list;

            list = (context.Protfolio.OrderByDescending(re => re.Last_updata_date)
                    .Select(re => new ServicesViewModel
            {
                Profilo_img = re.Photo_url, Description = re.Description, Color = re.Color_type
            })).Take(5).ToList();
            var vm = new Service_list_ViewModel {
                Project = list
            };

            return(vm);
        }
Example #14
0
        public Service_list_ViewModel GetService()
        {
            var context = new AppleLaLaModel();
            var repo    = new AppleLaLaRepository <Service>(context).GetAll();

            var data = (from r in repo
                        where r.Service_id != 30
                        select new ServicesViewModel
            {
                Service_name = r.Service_name,
                Service_photo = r.Service_photo_url
            }).Take(3).ToList();

            var result = new Service_list_ViewModel();

            result.three_Service = data;
            return(result);
        }
Example #15
0
        public Service_list_ViewModel GetPortfilo()
        {
            var context = new AppleLaLaModel();
            var list    = (from re in context.Protfolio
                           orderby re.Last_updata_date descending
                           select new ServicesViewModel
            {
                Profilo_img = re.Photo_url,
                Description = re.Description,
                Color = re.Color_type
            }).Take(5).ToList();

            var vm = new Service_list_ViewModel();

            vm.Project = list;

            return(vm);
        }
Example #16
0
        public decimal[] GetData(string[] name)
        {
            AppleLaLaModel context = new AppleLaLaModel();

            var rawData = from od in context.Order_details
                          join sd in context.Service_details on od.Service_details_Id equals sd.Service_details_Id
                          join st in context.Service_types on sd.Type_id equals st.Type_id
                          join s in context.Service on st.Service_id equals s.Service_id
                          select new { s.Service_id, s.Service_name, od.Order_detail_no, sd.Price };
            List <decimal> data = new List <decimal>();

            foreach (var item in name)
            {
                var num = rawData.Where((x) => x.Service_name == item).Sum((x) => x.Price);
                data.Add(num);
            }
            var result = data.ToArray();

            return(result);
        }
Example #17
0
        public object[] GetDataArray(string KeyName)
        {
            int            num     = DateTime.Now.Day;
            AppleLaLaModel context = new AppleLaLaModel();
            var            rawData = context.ForLineChart.Select(x => new { x.Name, x.Nday, x.Total })
                                     .Where((x) => x.Name == KeyName)
                                     .ToList();;

            object[] listRawData = new object[num];
            for (int i = 0; i < listRawData.Length; i++)
            {
                listRawData[i] = 0;
            }

            foreach (var input in rawData)
            {
                listRawData[(int)input.Nday - 1] = input.Total;
            }

            return(listRawData);
        }
Example #18
0
        public List <Datasets> GetAll()
        {
            AppleLaLaModel context = new AppleLaLaModel();
            //var countDays = DateTime.Now.Day;
            AppleLaLaRepository <Service> repo_service = new AppleLaLaRepository <Service>(context);
            var serviceName = repo_service.GetAll();

            List <Datasets> mainData  = new List <Datasets>();
            Random          color_rgb = new Random();

            foreach (var item in serviceName)
            {
                Datasets datasets = new Datasets();
                datasets.Name = item.Service_name;
                string color_str = string.Empty;
                color_str                     = $"rgba({color_rgb.Next(1, 255)},{color_rgb.Next(1, 255)},{color_rgb.Next(1, 255)},0.5)";
                datasets.BorderColor          = color_str;
                datasets.PointBackgroundColor = color_str;
                datasets.Data                 = GetDataArray(item.Service_name);
                mainData.Add(datasets);
            }

            return(mainData);
        }