Esempio n. 1
0
        public async Task <ActionResult <BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult> > > DeleteBackendMember([FromBody] BackendMemberViewModel.BackendSingleResult backendSingle)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + " BackendMembers控制器DeleteBackendMember方法被呼叫 ,傳入的資料為:" + $"Product controller Get called ,Parameter is {nameof(backendSingle.MemberId)} " + backendSingle.MemberId);

            var result = new BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult>();

            if (!ModelState.IsValid || backendSingle.MemberId == 2)
            {
                result.Msg       = "查無此筆資料";
                result.IsSuccess = false;

                return(result);
            }

            var deleteResult = await _backendMemberService.DeleteMember(backendSingle);

            result.Msg = deleteResult;
            if (result.Msg == "查無此筆資料")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "刪除成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 2
0
        public async Task <ActionResult <BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult> > > GetOneBackendMember(int id)
        {
            var result = new BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongDateString() + "BackendMembersController GetOneBackendMember方法被呼叫");

            try
            {
                var queryResult = await _backendMemberService.GetOne(id);

                if (queryResult == null)
                {
                    return(NotFound());
                }
                else
                {
                    result.Body = queryResult;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 3
0
        public BaseModel.BaseResult <ManagerViewModel.ManagerSingleResult> CreateManager([FromBody] ManagerViewModel.ManagerSingleResult manager)
        {
            var     result     = new BaseModel.BaseResult <ManagerViewModel.ManagerSingleResult>();
            Manager newManager = null;

            newManager = new Manager
            {
                ManagerName     = manager.ManagerName,
                ManagerPassword = manager.ManagerPassword,
                ManagerUsername = manager.ManagerUserName,
                ManagerRoleId   = manager.ManagerRoleID
            };

            try
            {
                _repository.Create <Manager>(newManager);
                if (newManager != null)
                {
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                result.IsSuccess = false;
            }
            return(result);
        }
Esempio n. 4
0
        public async Task <ActionResult <BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult> > > PutBackendMember([FromBody] BackendMemberViewModel.BackendSingleResult backendSingle)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + " BackendMembers控制器PutBackendMember方法被呼叫 ,傳入的資料為:" + System.Text.Json.JsonSerializer.Serialize(backendSingle));

            var result = new BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult>();

            if (!ModelState.IsValid)
            {
                result.Msg       = "查無此筆資料";
                result.IsSuccess = false;

                return(result);
            }

            var editResult = await _backendMemberService.EditMember(backendSingle);

            result.Msg = editResult;
            if (result.Msg == "查無此筆資料")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "修改成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
        public async Task <ActionResult <BaseModel.BaseResult <ProjectViewModel.ProjectSingleResult> > > EditWaitForPassProject([FromBody] ProjectViewModel.ProjectSingleResult waitForPassSingle)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + " BackendMembers控制器PutBackendMember方法被呼叫 ,傳入的資料為:" + System.Text.Json.JsonSerializer.Serialize(waitForPassSingle));

            var result = new BaseModel.BaseResult <ProjectViewModel.ProjectSingleResult>();

            var editResult = await _projectService.EditWaitForPassProject(waitForPassSingle);

            result.Msg = editResult;
            if (result.Msg == "查無此筆資料")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "修改成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 6
0
        public BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult> GetBackendAuthentication(LoginViewModel loginVM)
        {
            var result  = new BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult>();
            var manager = _repository.GetAll <Backendmember>().Where(x => x.MemberRegEmail == loginVM.MemberRegEmail && x.MemberPassword == loginVM.Password).FirstOrDefault();

            try
            {
                if (manager != null)
                {
                    if (manager.BackendIdentity == true)
                    {
                        result.IsSuccess = true;
                        result.Msg       = manager.BackendIdentity.ToString();
                    }
                    else
                    {
                        result.IsSuccess = true;
                        result.Msg       = manager.BackendIdentity.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                ex.ToString();
            }

            return(result);
        }
        /// <summary>
        /// 從前端修改資料庫會員資料,回傳型式為字串。共有三種型式"查無此筆資料"、"修改成功"及例外的資訊
        /// </summary>
        /// <param name="backendSingle"></param>
        /// <returns></returns>
        public async Task <ActionResult <BaseModel.BaseResult <CarCarPlanViewModel.CarCarPlanSingleResult> > > PutCarCarPlan(CarCarPlanViewModel.CarCarPlanSingleResult carCarPlanVM)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + " CarCarPlans控制器PutCarCarPlan方法被呼叫 ,傳入的資料為:" + $"Product controller Get called ,Parameter is {nameof(carCarPlanVM.PlanId)} " + carCarPlanVM.PlanId);

            var result = new BaseModel.BaseResult <CarCarPlanViewModel.CarCarPlanSingleResult>();

            if (!ModelState.IsValid)
            {
                result.Msg       = "查無此筆資料";
                result.IsSuccess = false;

                return(result);
            }

            var editResult = await _carCarPlanService.EditCarCarPlan(carCarPlanVM);

            result.Msg = editResult;

            if (result.Msg == "查無此筆資料")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "修改成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 8
0
        public async Task <ActionResult <BaseModel.BaseResult <MailViewModel.MailBaseSingleViewModel> > > SendMail([FromBody] MailViewModel.MailBaseSingleViewModel mailBaseSingleVM)
        {
            return(await Task.Run(() =>
            {
                var result = new BaseModel.BaseResult <MailViewModel.MailBaseSingleViewModel>();

                _logger.LogWarning(2001, DateTime.Now.ToLongDateString() + "MailsController SendMail方法被呼叫");

                if (!ModelState.IsValid)
                {
                    result.Msg = "查無此Eamil";

                    result.IsSuccess = false;

                    return result;
                }

                var queryResult = _repository.GetAll <Member>().FirstOrDefault(M => M.MemberRegEmail == mailBaseSingleVM.MemberRegEmail);

                if (queryResult == default)
                {
                    result.Msg = "查無此Eamil";

                    result.IsSuccess = false;

                    return result;
                }


                //取Email template
                string returnData = getEmailData();

                //把該帶的資料塞進 template
                string finalReturnData = setReplacedEmailData(returnData, mailBaseSingleVM.MailBody, queryResult.MemberName);

                var msg = new MailMessage("*****@*****.**",
                                          queryResult.MemberRegEmail, "集資車車 - 管理員通知:" + mailBaseSingleVM.MailTitle,
                                          finalReturnData);

                msg.IsBodyHtml = true;

                string id = _configuration.GetValue <string>("Gmail:Id");
                string password = _configuration.GetValue <string>("Gmail:Password");

                var client = new SmtpClient("smtp.gmail.com", 587)
                {
                    Credentials = new NetworkCredential(id, password),
                    EnableSsl = true,
                };
                //client.Send(mailVM.sender, mailVM.receiver, mailVM.MailTitle, mailVM.MailBody);
                client.Send(msg);

                result.Msg = mailBaseSingleVM.MailTitle + mailBaseSingleVM.MailBody;

                return result;
            }));
        }
Esempio n. 9
0
        public BaseModel.BaseResult <ExhibitonViewModel.ExhibitonListResult> GetTodayExhibiton()
        {
            var result = new BaseModel.BaseResult <ExhibitonViewModel.ExhibitonListResult>();

            try
            {
                result.Body = _service.GetTodayExhibiton();
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 10
0
        public BaseModel.BaseResult <RentalViewModel.RentalListResult> GetRentalDate()
        {
            var result = new BaseModel.BaseResult <RentalViewModel.RentalListResult>();

            try
            {
                result.Body = _service.RentalGetAll();
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 11
0
        public BaseModel.BaseResult <OrderViewModel.OrderListResult> GetMonthOrderPrice(int month)
        {
            BaseModel.BaseResult <OrderViewModel.OrderListResult> result = new BaseModel.BaseResult <OrderViewModel.OrderListResult>();
            result.Body = _orderService.GetMonthOrderPrice(month);

            try
            {
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 12
0
        public BaseModel.BaseResult <ExhibitonEmailViewModel.EmailListResult> GetEmailData()
        {
            var result = new BaseModel.BaseResult <ExhibitonEmailViewModel.EmailListResult>();

            try
            {
                int i = 1;
                result.Body = _service.EmailGetAll(i);
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 13
0
        public BaseModel.BaseResult <OrderViewModel.OrderListResult> GetByMemberId(int id)
        {
            var result = new BaseModel.BaseResult <OrderViewModel.OrderListResult>();

            try
            {
                result.Body = _memberService.GetByMemberId(id);
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 14
0
        public BaseModel.BaseResult <ProductViewModels.ProductSingleResult> Edit(ProductViewModels.ProductSingleResult productVM)
        {
            BaseModel.BaseResult <ProductViewModels.ProductSingleResult> result = new BaseModel.BaseResult <ProductViewModels.ProductSingleResult>();
            result.Body = productVM;
            try
            {
                result.IsSuccess = _productService.Edit(productVM);
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 15
0
        public BaseModel.BaseResult <AnnouncementViewModel.AnnouncementListResult> GetAll()
        {
            var result = new BaseModel.BaseResult <AnnouncementViewModel.AnnouncementListResult>();

            try
            {
                result.Body = _announcementService.GetAll();
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 16
0
        public BaseModel.BaseResult <MemberViewModel.MemberSingleResult> Edit(MemberViewModel.MemberSingleResult memberVM)
        {
            BaseModel.BaseResult <MemberViewModel.MemberSingleResult> result = new BaseModel.BaseResult <MemberViewModel.MemberSingleResult>();
            result.Body = memberVM;

            try
            {
                result.IsSuccess = _memberService.Edit(memberVM);
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 17
0
        public BaseModel.BaseResult <CategoryViewModel.CategoryListResult> GetAll()
        {
            var result = new BaseModel.BaseResult <CategoryViewModel.CategoryListResult>();

            try
            {
                result.Body = _categoryService.GetAll();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 18
0
        public async Task <ActionResult <BaseModel.BaseResult <OrderViewModel.OrderListResult> > > GetAll()
        {
            var result = new BaseModel.BaseResult <OrderViewModel.OrderListResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + "Products控制器Get方法被呼叫, by" + UriHelper.GetDisplayUrl(Request)); //確認前後參數是否一致
            try
            {
                result.Body = await _orderService.GetAll();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 19
0
        public BaseModel.BaseResult <ManagerViewModel.ManagerListResult> GetAllManagers()
        {
            var result = new BaseModel.BaseResult <ManagerViewModel.ManagerListResult>();

            try
            {
                result.Body = _manageService.GetAllManagers();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 20
0
        public BaseModel.BaseResult <ProductViewModels.ProductListResult> GetByCategory(int CategoryId)
        {
            var result = new BaseModel.BaseResult <ProductViewModels.ProductListResult>();

            try
            {
                result.Body = _productService.GetByCategory(CategoryId);

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 21
0
        public BaseModel.BaseResult <List <ProductViewModels.ProductSingleResult> > EditIsSpecial(List
                                                                                                  <ProductViewModels.ProductSingleResult> productVMList)
        {
            BaseModel.BaseResult <List <ProductViewModels.ProductSingleResult> > result = new BaseModel.BaseResult
                                                                                          <List <ProductViewModels.ProductSingleResult> >();
            try
            {
                result.IsSuccess = _productService.EditIsSpecial(productVMList);
                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
        public async Task <BaseModel.BaseResult <CarCarPlanViewModel.CarCarPlanListResult> > GetAll()
        {
            var result = new BaseModel.BaseResult <CarCarPlanViewModel.CarCarPlanListResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongDateString() + "CarCarPlansController GetAll方法被呼叫");

            try
            {
                result.Body = await _carCarPlanService.GetAll();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
        public async Task <BaseModel.BaseResult <ProjectViewModel.ProjectListResult> > GetWaitForPass()
        {
            var result = new BaseModel.BaseResult <ProjectViewModel.ProjectListResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + "Projects控制器GET方法被呼叫, by" + UriHelper.GetDisplayUrl(Request));

            try
            {
                result.Body = await _projectService.GetWaitForPass();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 24
0
        public BaseModel.BaseResult <ManagerViewModel.ManagerSingleResult> GetManagerAuthentication(LoginViewModel loginVM)
        {
            var result  = new BaseModel.BaseResult <ManagerViewModel.ManagerSingleResult>();
            var manager = _repository.GetAll <Manager>().Where(x => x.ManagerName == loginVM.Username && x.ManagerPassword == loginVM.Password).FirstOrDefault();

            try
            {
                if (manager != null)
                {
                    result.IsSuccess = true;
                    result.Msg       = manager.ManagerRoleId.ToString();
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                ex.ToString();
            }

            return(result);
        }
Esempio n. 25
0
        public async Task <ActionResult <BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult> > > PostBackendMember([FromBody] BackendMemberViewModel.BackendSingleResult backendSingle)
        {
            var result = new BaseModel.BaseResult <BackendMemberViewModel.BackendSingleResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + " BackendMembers控制器PostBackendMember方法被呼叫 ,傳入的資料為:" + System.Text.Json.JsonSerializer.Serialize(backendSingle));



            try
            {
                result.Body = await _backendMemberService.CreateOneMember(backendSingle);



                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 26
0
        public async Task <ActionResult <BaseModel.BaseResult <OrderViewModel.OrderSingleResult> > > DeleteOrder([FromBody] OrderViewModel.OrderSingleResult orderSingle)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + "Products控制器Delete方法被呼叫, by" + UriHelper.GetDisplayUrl(Request)); //確認前後端參數是否一致
            var result      = new BaseModel.BaseResult <OrderViewModel.OrderSingleResult>();                                             //刪除單一筆資料
            var deleteOrder = await _orderService.DeleteOrder(orderSingle);

            result.Msg = deleteOrder; //刪除成功 或 錯誤訊息
            if (result.Msg == "無匹配訂單")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "刪除成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 27
0
        public async Task <BaseModel.BaseResult <BackendMemberViewModel.BackendListResult> > GetAll()
        {
            //var result = Members.Join(Projects, m => m.MemberId, p => p.MemberId, (m, p) => new { m.MemberId, m.MemberRegEmail, m.MemberBirth, p.ProjectId, p.ProjectName, p.FundingAmount, p.AmountThreshold, p.StartDate, p.EndDate, p.ProjectStatus })
            //.Join(Plans, p => p.ProjectId, pl => pl.ProjectId, (p, pl) => new { p.MemberId, p.MemberRegEmail, p.ProjectId, p.ProjectName, pl.PlanId, pl.PlanTitle, pl.AddCarCarPlan });

            var result = new BaseModel.BaseResult <BackendMemberViewModel.BackendListResult>();

            _logger.LogWarning(2001, DateTime.Now.ToLongDateString() + "BackendMembersController GetAll方法被呼叫");

            try
            {
                result.Body = await _backendMemberService.GetAll();

                return(result);
            }
            catch (Exception ex)
            {
                result.Msg       = ex.Message;
                result.IsSuccess = false;

                return(result);
            }
        }
Esempio n. 28
0
        public async Task <ActionResult <BaseModel.BaseResult <OrderViewModel.OrderSingleResult> > > UpdateOrder([FromBody] OrderViewModel.OrderSingleResult orderSingle)
        {
            _logger.LogWarning(2001, DateTime.Now.ToLongTimeString() + "Products控制器PUT方法被呼叫-傳入的資料為:" + System.Text.Json.JsonSerializer.Serialize(orderSingle));

            var result      = new BaseModel.BaseResult <OrderViewModel.OrderSingleResult>();
            var updateOrder = await _orderService.UpdateOrder(orderSingle);

            result.Msg = updateOrder;
            if (result.Msg == "查無此筆訂單")
            {
                result.IsSuccess = false;
                return(result);
            }
            else if (result.Msg == "更新成功")
            {
                result.IsSuccess = true;
                return(result);
            }
            else
            {
                result.IsSuccess = false;
                return(result);
            }
        }
Esempio n. 29
0
        public BaseModel.BaseResult <ProductViewModels.ProductSingleResult> AddProduct([FromBody] ProductViewModels.ProductSingleResult productVM)
        {
            var     result     = new BaseModel.BaseResult <ProductViewModels.ProductSingleResult>();
            Product newProduct = null;



            newProduct = new Product
            {
                ProductName  = productVM.ProductName,
                ProductId    = productVM.ProductId,
                CategoryId   = productVM.CategoryId,
                Introduction = productVM.Introduction,
                SupplierId   = productVM.SupplierId,
                Author       = productVM.Author,
                Inventory    = productVM.Inventory,
                TotalSales   = productVM.TotalSales,
                IsSpecial    = productVM.IsSpecial,
                UnitPrice    = productVM.UnitPrice,
                Isbn         = productVM.Isbn,
                CreateTime   = DateTime.UtcNow.AddHours(8),
                Sort         = 0
            };

            try
            {
                _dbRepository.Create <Product>(newProduct);
                if (newProduct != null)
                {
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Msg       = ex.ToString();
            }



            //圖片
            Preview mainPreview = new Preview()
            {
                ProductId = newProduct.ProductId,
                ImgUrl    = productVM.MainUrl,
                Sort      = 0,
            };

            try
            {
                _dbRepository.Create(mainPreview);
                if (mainPreview != null)
                {
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Msg       = ex.ToString();
            }


            int i = 0;

            foreach (string previewUrl in productVM.PreviewUrls)
            {
                i++;
                Preview preview = new Preview()
                {
                    ProductId = newProduct.ProductId,
                    ImgUrl    = previewUrl,
                    Sort      = i,
                };
                try
                {
                    _dbRepository.Create(preview);
                    if (preview != null)
                    {
                        result.IsSuccess = true;
                    }
                }
                catch (Exception ex)
                {
                    result.IsSuccess = false;
                    result.Msg       = ex.ToString();
                }
            }



            return(result);
        }