コード例 #1
0
        public ActionResult Edit(int id)
        {
            var news = new NewService().ViewDetail(id);

            SetViewBagNew(news.NewCategoryID);
            return(View(news));
        }
コード例 #2
0
 public ActionResult Search(string search = "")
 {
     ViewBag.search   = NewService.FindSuitableNews(search);
     ViewBag.tags     = TagService.GetTagsList();
     ViewBag.isSearch = true;
     return(View("StartPage"));
 }
コード例 #3
0
 public ActionResult SearchCategory(string search)
 {
     ViewBag.search   = NewService.SearchCategoryNews(search);
     ViewBag.tags     = TagService.GetTagsList();
     ViewBag.isSearch = true;
     return(View("StartPage"));
 }
コード例 #4
0
        public HttpResponseMessage PostFile(News Noticia)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (NewService service = new NewService())
                {
                    service.NewInsert(Noticia.new_id, Noticia.descripcion, Noticia.fileToUpload, Noticia.titulo, Noticia.expired, Noticia.Active);
                    data.result  = null;
                    data.status  = true;
                    data.message = Noticia.new_id == 0 ? "Se creo la noticia":"Se actualizó corretamenta la noticia";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
コード例 #5
0
        public HttpResponseMessage ObtenerNoticias()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (NewService service = new NewService())
                {
                    var Noticias = service.TodasLasNoticias();
                    data.result = new { Noticias };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Noticias");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
コード例 #6
0
        public HttpResponseMessage DeleletComplain(int news_id)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (NewService service = new NewService())
                {
                    service.Delete(news_id);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Se ha eliminado la noticia";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Eliminar queja");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
コード例 #7
0
        public HttpResponseMessage CardData()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (NewService service = new NewService())
                {
                    service.CardData(config.usuario.usuario_Id);
                    data.result = new { service.outstandingcomplaints, service.outstandingdenounces, service.attendedcomplaints, service.attendeddenounces };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Card data");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
コード例 #8
0
ファイル: TermServie.cs プロジェクト: xuannam120392/webtest
        public TermViewModels GetTermContent()
        {
            var data        = new TermViewModels();
            var config      = new ConfigService();
            var category    = new CategoryService();
            var news        = new NewService();
            var block       = new BlockService();
            var menuService = new MenuService();

            data.ListNewFeature = news.GetListNew_Category(11).ToList();
            data.TermValue      = config.GetConfigById("PRIVACY_TITLE").Value;
            data.TermDesc       = category.GetCategoryById("11").DESC;
            data.BlockFooter    = block.GetBlockBySection("5");
            data.HotLineTitle   = config.GetConfigById("HOTLINE_TITLE").Value;
            data.HotLine        = config.GetConfigById("HOTLINE").Value;
            data.SiteMain       = config.GetConfigById("SITE_MAIN").Value;
            data.ContactTitle   = config.GetConfigById("CONTACT_TITLE").Value;
            data.CopyRight      = config.GetConfigById("COPY_RIGHT").Value;
            data.QuestionTitle  = config.GetConfigById("QUESTION_TITLE").Value;
            data.MenuListModel  = menuService.GetListMenuView("1");
            data.TitleMain      = config.GetConfigById("TITLE_MAIN").Value;
            data.DescMain       = config.GetConfigById("DESC_MAIN").Value;
            data.Keyword        = config.GetConfigById("KEYWORD").Value;
            data.LinkFace       = config.GetConfigById("LINK_FACE").Value;
            data.LinkedIn       = config.GetConfigById("LINK_LINKEDIN").Value;
            data.LinkYoutube    = config.GetConfigById("LINK_YOUTUBE").Value;
            return(data);
        }
コード例 #9
0
 public string Load()
 {
     try {
         connection.Open();
         SqlCommand        command  = new SqlCommand(@"SELECT [Id], [ClientId], [Service], [Option], [Quantity], [Unit], [Price], [ActivationDate], [ExpirationDate], [QuantityLeft], [IsPaid], [IsFreezed] FROM ClientServices
                                         ORDER BY Id DESC", connection);
         SqlDataReader     reader   = command.ExecuteReader();
         List <NewService> services = new List <NewService>();
         while (reader.Read())
         {
             NewService xx = new NewService()
             {
                 id             = reader.GetInt32(0),
                 clientId       = reader.GetInt32(1),
                 service        = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2),
                 option         = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3),
                 quantity       = reader.GetValue(4) == DBNull.Value ? 0 : reader.GetInt32(4),
                 unit           = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5),
                 price          = reader.GetValue(6) == DBNull.Value ? "" : reader.GetString(6),
                 activationDate = reader.GetValue(7) == DBNull.Value ? DateTime.UtcNow : reader.GetDateTime(7).AddHours(timeDiff),
                 expirationDate = reader.GetValue(8) == DBNull.Value ? DateTime.UtcNow : reader.GetDateTime(8).AddHours(timeDiff),
                 quantityLeft   = reader.GetValue(9) == DBNull.Value ? 0 : reader.GetInt32(9),
                 isPaid         = Convert.ToBoolean(reader.GetInt32(10)),
                 isFreezed      = Convert.ToBoolean(reader.GetInt32(11))
             };
             services.Add(xx);
         }
         connection.Close();
         string json = JsonConvert.SerializeObject(services, Formatting.Indented);
         return(json);
     } catch (Exception e) { return("Error: " + e); }
 }
コード例 #10
0
 public string GetActiveClientServices(Int32 clientId)
 {
     try {
         connection.Open();
         SqlCommand command = new SqlCommand(@"SELECT DISTINCT [Id], [ClientId], [Service], [Option], [Quantity], [Unit], [Price], [ActivationDate], [ExpirationDate], [QuantityLeft], [IsPaid], [IsFreezed] FROM ClientServices
                                         WHERE ClientId = @ClientId AND [ActivationDate] <= GETDATE() AND [ExpirationDate] >= GETDATE() AND QuantityLeft > 0
                                         GROUP BY [Id], [ClientId], [Service], [Option], [Quantity], [Unit], [Price], [ActivationDate], [ExpirationDate], [QuantityLeft], [IsPaid], [IsFreezed]
                                         ORDER BY [Service] ASC", connection);
         command.Parameters.Add(new SqlParameter("ClientId", clientId));
         SqlDataReader     reader         = command.ExecuteReader();
         List <NewService> clientServices = new List <NewService>();
         while (reader.Read())
         {
             NewService xx = new NewService()
             {
                 id             = reader.GetInt32(0),
                 clientId       = reader.GetInt32(1),
                 service        = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2),
                 option         = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3),
                 quantity       = reader.GetValue(4) == DBNull.Value ? 0 : reader.GetInt32(4),
                 unit           = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5),
                 price          = reader.GetValue(6) == DBNull.Value ? "" : reader.GetString(6),
                 activationDate = reader.GetValue(7) == DBNull.Value ? DateTime.UtcNow : reader.GetDateTime(7).AddHours(timeDiff),
                 expirationDate = reader.GetValue(8) == DBNull.Value ? DateTime.UtcNow.AddDays(31) : reader.GetDateTime(8).AddHours(timeDiff),
                 quantityLeft   = reader.GetValue(9) == DBNull.Value ? 0 : reader.GetInt32(9),
                 isPaid         = Convert.ToBoolean(reader.GetInt32(10)),
                 isFreezed      = Convert.ToBoolean(reader.GetInt32(11))
             };
             clientServices.Add(xx);
         }
         connection.Close();
         string json = JsonConvert.SerializeObject(clientServices, Formatting.Indented);
         return(json);
     } catch (Exception e) { return("Error: " + e); }
 }
コード例 #11
0
    public string Update(NewService clientService)
    {
        try {
            connection.Open();
            string sql = @"UPDATE ClientServices SET  
                        [Service] = @Service, [Option] = @Option, [Quantity] = @Quantity, [Unit] = @Unit, [Price] = @Price, [ActivationDate] = @ActivationDate, [ExpirationDate] = @ExpirationDate, [QuantityLeft] = @QuantityLeft, [IsPaid] = @IsPaid, [IsFreezed] = @IsFreezed
                        WHERE [ClientId] = @ClientId AND [Id] = @Id";

            SqlCommand command = new SqlCommand(sql, connection);
            command.Parameters.Add(new SqlParameter("Id", clientService.id));
            command.Parameters.Add(new SqlParameter("ClientId", clientService.clientId));
            command.Parameters.Add(new SqlParameter("Service", clientService.service));
            command.Parameters.Add(new SqlParameter("Option", clientService.option));
            command.Parameters.Add(new SqlParameter("Quantity", clientService.quantity));
            command.Parameters.Add(new SqlParameter("Unit", clientService.unit));
            command.Parameters.Add(new SqlParameter("Price", clientService.price));
            command.Parameters.Add(new SqlParameter("ActivationDate", clientService.activationDate));
            command.Parameters.Add(new SqlParameter("ExpirationDate", clientService.expirationDate));
            command.Parameters.Add(new SqlParameter("QuantityLeft", clientService.quantityLeft));
            command.Parameters.Add(new SqlParameter("IsPaid", clientService.isPaid));
            command.Parameters.Add(new SqlParameter("IsFreezed", clientService.isFreezed));
            command.ExecuteNonQuery();
            connection.Close();
            return("OK");  // Load();
        } catch (Exception e) { return("Update failed! (Error: )" + e); }
    }
コード例 #12
0
        public JSONResult <List <New> > GetNesList(string kw, int pageIndex, int pageSize)
        {
            return(new BaseJsonResult().UnifiedFucn(() =>
            {
                var model = new JSONResult <List <New> >();
                model.Success = true;
                if (pageIndex == 0)
                {
                    pageIndex = 1;
                }
                if (pageSize == 0)
                {
                    pageSize = 8;
                }
                NewService service = new NewService();
                var newList = service.GetNewListByPage(kw, pageIndex, pageSize);
                if (newList.Count > 0)
                {
                    model.ret = 0;
                    model.Result = "获取数据成功";
                    model.Content = newList;
                }
                else
                {
                    model.ret = 5;
                    model.Result = "没有更多记录";
                    model.Content = newList;
                }

                return model;
            }));
        }
コード例 #13
0
        // GET: Admin/NewAdmin
        public ActionResult Index(string search, int page = 1, int pageSize = 4)
        {
            var service = new NewService();
            var model   = service.DanhSachNPaging(search).ToPagedList(page, pageSize);

            ViewBag.Search = search;
            return(View(model));
        }
コード例 #14
0
        public ActionResult UserRoom(string login)
        {
            DBUser author = UserService.ReturnClass(login);

            ViewBag.author   = author;
            ViewBag.newsUser = NewService.GetNewsAuthor(author);
            return(View());
        }
コード例 #15
0
        public JsonResult ChangeStatus(int id)
        {
            var result = new NewService().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
コード例 #16
0
 //切换右上角 人次/人数时,需要调用此方法
 public void BindCategoryList()
 {
     categoryEntityList = NewService.GetStudentCategoryList(CurrUserInfo.SchoolId).Where(p => p.DataType == dataType).ToList();
     categoryList       = new List <string>(categoryEntityList.Select(t => t.CategoryName).ToArray());
     searchCagetory     = categoryList[0];
     tv_cagetory.Text   = searchCagetory;
     //重置查询弹框,否则adapter不会更新
     popCategory = null;
 }
コード例 #17
0
        public void BindData()
        {
            LoadingDialogUtil.ShowLoadingDialog(CurrActivity, "获取数据中...");

            try
            {
                var schoolId       = CurrUserInfo.SchoolId;
                var year           = searchQuarter.Year;
                var quarter        = searchQuarter.Quarter;
                var district       = searchDistrict;
                var categoryEntity = categoryEntityList.FirstOrDefault(p => p.CategoryName == searchCagetory);
                var category       = categoryEntity == null?"":categoryEntity.CategoryValue;

                //负责校区
                var areaCodes = "";                 //店长登录用
                if (CurrUserInfo.Type == (int)UserType.ShopManager)
                {
                    areaCodes = CurrUserInfo.AreaCodes;
                }
                //年级
                var gradeList = RenewService.GetGradeList(CurrUserInfo.SchoolId);
                var grade     = string.Join(",", gradeList.Select(p => p.GradeName));

                new System.Threading.Thread(new ThreadStart(() =>
                {
                    var list = NewService.GetSumNewStudentList(schoolId, year, quarter, dataType, sortType, district, category, grade, out totalCount, 1, 1, 500, areaCodes);
                    CurrActivity.RunOnUiThread(() =>
                    {
                        LoadingDialogUtil.DismissLoadingDialog();
                        mSwipeRefreshLayout.Refreshing = false;

                        if (list != null)
                        {
                            var totalData      = list.TotalData;
                            this.avgGrowthRate = totalData.Rate;
                            this.sumList       = list.List;
                            var totalEntity    = new NewStudentSumAreaEntity()
                            {
                                Name = totalData.Name, StudentCount = totalData.StudentCount, Total = totalData.Total, Rate = totalData.Rate
                            };
                            this.sumList.Add(totalEntity);


                            mAdapter.SetData(this.sumList, this.avgGrowthRate);
                            mAdapter.NotifyDataSetChanged();
                        }
                    });
                })).Start();
            }
            catch (Exception ex)
            {
                var msg = ex.Message.ToString();
                LoadingDialogUtil.DismissLoadingDialog();
                mSwipeRefreshLayout.Refreshing = false;
            }
        }
コード例 #18
0
 public HomeController()
 {
     filmService     = new FilmService();
     showtimeService = new ShowtimeService();
     roomService     = new RoomService();
     seatService     = new SeatService();
     cinemaService   = new CinemaService();
     ticketService   = new TicketService();
     newService      = new NewService();
 }
コード例 #19
0
 private void FillData()
 {
     CategoryService.FillCategory();
     TagService.FillTags();
     AccountController.AddCategor();
     AccountController.AddTags();
     NewService.GetNews();
     RatingService.SetRating();
     CommentsService.GetCountComments();
 }
コード例 #20
0
    public static void Main()
    {
        Client client = new Client(new Service());

        client.Start();

        NewService newService        = new NewService();
        Client     clientNewFunction = new Client(newService);

        clientNewFunction.Start();
    }
コード例 #21
0
        public ActionResult Detail(string id)
        {
            //NewModel model = new NewModel();
            NewService news = new NewService();
            //model = news.GetNewById(id);
            //model = news.GetNewById(id);
            EventViewModels model        = new EventViewModels();
            var             EventService = new EventService();

            model = EventService.GetEventDetailContent(id);
            return(View(model));
        }
コード例 #22
0
 public FirstViewModel(ProductService productservice,
                       SolutionService solutionservice,
                       CarouselService sarouselService,
                       NewService newService,
                       VideoService videoservice)
 {
     //Location = location;
     whichSite       = Common.Site.CompanyHeadquarter;
     ProductService  = productservice;
     Solutionservice = solutionservice;
     NewService      = newService;
     VideoService    = videoservice;
     CarouselService = sarouselService;
 }
コード例 #23
0
 private async Task <HttpResponseMessage> CreateResponse(string itemName, BadgeType type, string subject, string color, string ext)
 {
     //Loggly.SendAccess(itemName, type, subject, color, ext).FireAndForget();
     //var status = await VsMarketplace.Load(itemName, type);
     //var res = Request.CreateResponse(HttpStatusCode.OK);
     //res.Content = new ByteArrayContent(await ShieldsIo.LoadSvg(subject, status, color, Request.RequestUri.Query, ext));
     //res.Content.Headers.ContentType = new MediaTypeHeaderValue(mimeMap[ext]);
     //res.Headers.CacheControl = new CacheControlHeaderValue()
     //{
     //    NoCache = true
     //};
     //return res;
     return(await NewService.Relay(Request.RequestUri));
 }
コード例 #24
0
        [Step(@"^we prepare for a new service$")] public void PrepareNewService()
        {
            assetDb?.Dispose();
            assetDb = AssetDb.Instance;
            assetDb.CreateFolders(path: projectDirectory).Select();
            if (assetDb.Error)
            {
                Fail($"Can't create '{projectDirectory}'");
            }

            assetEditor?.Dispose();
            assetEditor = AssetEditor.Instance.Load(assetName: "NewService", nameSpace: "Decoupler", projectDirectory);
            newService  = (NewService)assetEditor.Asset("NewService");
            Clear();
        }
コード例 #25
0
 public ActionResult StartPage()
 {
     ViewBag.tags = TagService.GetTagsList();
     if (!fillDataLists)
     {
         fillDataLists = !fillDataLists;
         FillData();
     }
     AccountController.wrongEmail  = false;
     AccountController.isSave      = false;
     AccountController.largeLenght = false;
     NewService.SetLike();
     ViewBag.search = NewService.newStack;
     NewService.FillParameters();
     return(View());
 }
コード例 #26
0
        public ActionResult ReadNews(int newsId, int numberNews)
        {
            Stack <Comment> comments = new Stack <Comment>();

            NewService.currentStateNews = NewService.GetNew(newsId);
            comments = CommentsService.GetListComments(NewService.currentStateNews);
            JsonController.countComments = CommentsService.GetCountComments();


            List <int> countLikeList = new List <int>();
            int        rating        = 0;

            using (SampleContext context = new SampleContext())
            {
                foreach (var item in comments)
                {
                    var rowUser = context.users.SingleOrDefault(x => x.userId == item.userId);
                    if (rowUser != null)
                    {
                        if (rowUser.countLike >= 0)
                        {
                            countLikeList.Add(rowUser.countLike);
                        }
                    }
                    else
                    {
                        countLikeList.Add(0);
                    }
                }
                try
                {
                    int countLikeUser = context.users.SingleOrDefault(x => x.userId == NewService.currentStateNews.userId).countLike;
                    rating = countLikeUser;
                }
                catch { }
            }

            ViewBag.countLike      = rating;
            ViewBag.usersCountLike = countLikeList;
            ViewBag.comment        = comments;
            ViewBag.news           = NewService.currentStateNews;
            ViewBag.numberNews     = numberNews;
            return(View());
        }
コード例 #27
0
        static void Main(string[] args)
        {
            Console.WriteLine("测试 Cilador.Fody。    不使用继承, 而重用代码.");



            dynamic test = new NewService();


            Console.WriteLine("重用旧的类库的实现1:{0}", test.Hello());
            Console.WriteLine("重用旧的类库的实现2:{0}", test.Hello2());



            Console.WriteLine("自己类中新增加的实现:{0}", test.NewHello());


            Console.ReadKey();
        }
コード例 #28
0
 public ActionResult CreateNew(News news)
 {
     if (ModelState.IsValid)
     {
         var service = new NewService();
         int id      = service.Insert(news);
         if (id > 0)
         {
             SetAlert("Thêm bài viết thành công!", "success");
             return(RedirectToAction("Index", "NewAdmin"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm bài viết mới thất bại!");
         }
     }
     SetViewBagNew(news.NewCategoryID);
     return(View("Index"));
 }
コード例 #29
0
 public ActionResult Edit(News news)
 {
     if (ModelState.IsValid)
     {
         var service = new NewService();
         var result  = service.Update(news);
         if (result)
         {
             SetAlert("Cập nhật bài viết thành công!", "success");
             return(RedirectToAction("Index", "NewAdmin"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật bài viết thất bại!");
         }
     }
     SetViewBagNew(news.NewCategoryID);
     return(View("Index"));
 }
コード例 #30
0
        public HttpResponseMessage getNewsFilter(string expired, string filter)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                if (expired == "_ALL_")
                {
                    expired = "";
                }

                if (filter == "_ALL_")
                {
                    filter = "";
                }


                using (NewService service = new NewService())
                {
                    var Noticias = service.GETNEWSFILTER(expired, filter);
                    data.result = new { Noticias };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Noticias");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }