public async Task <IActionResult> Create([Bind("Id,ProjectKey,VersionNumber,UpdateRequired")] Settings settings)
        {
            if (ModelState.IsValid)
            {
                settings.Id = Guid.NewGuid();
                _context.Add(settings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(settings));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Password,Email")] Users users)
        {
            if (ModelState.IsValid)
            {
                users.Id = Guid.NewGuid();
                _context.Add(users);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("Id,Token,Device,CreateDate")] NotificationToken notificationToken)
        {
            if (ModelState.IsValid)
            {
                notificationToken.Id = Guid.NewGuid();
                _context.Add(notificationToken);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(notificationToken));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("Id,DrawersId,Rank")] Cartoon cartoon)
        {
            if (ModelState.IsValid)
            {
                cartoon.Id = Guid.NewGuid();
                _context.Add(cartoon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DrawersId"] = new SelectList(_context.Drawer, "Id", "Name", cartoon.DrawersId);
            return(View(cartoon));
        }
        public async Task <IActionResult> Create([Bind("Id,CartoonId,UniqUserKey")] CartoonLikes cartoonLikes)
        {
            if (ModelState.IsValid)
            {
                cartoonLikes.Id = Guid.NewGuid();
                _context.Add(cartoonLikes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CartoonId"] = new SelectList(_context.Cartoon, "Id", "Id", cartoonLikes.CartoonId);
            return(View(cartoonLikes));
        }
        public async Task <IActionResult> Create(SendNotificationCpx notification)
        {
            notification.Id = Guid.NewGuid();
            _context.Add(notification);
            var result = await _context.SaveChangesAsync();

            if (result > 0)
            {
                string[] tokenList = new string[] { };
                var      query     = _context.NotificationToken.AsQueryable();
                if (notification.IsOnlyAndroid)
                {
                    query = query.Where(x => x.Platform == "android");
                    if (notification.LastLoginWithDate != 0)
                    {
                        query = query.Where(x => x.UpdateDate.AddDays(notification.LastLoginWithDate) < DateTime.Now);
                    }
                }
                else
                {
                    if (notification.LastLoginWithDate != 0)
                    {
                        query = query.Where(x => x.UpdateDate.AddDays(notification.LastLoginWithDate) < DateTime.Now);
                    }
                }
                query.Where(x => x.Settings.ProjectKey == "KarikaturMadeni");
                tokenList = await query.Select(x => x.Token).ToArrayAsync();

                if (tokenList.Length > 0)
                {
                    RestClient client  = new RestClient("https://exp.host/--/api/v2/push/send");
                    var        request = new RestRequest(Method.POST);
                    client.Timeout = -1;
                    request.AddHeader("content-type", "application/json");
                    request.AddParameter("application/json", JsonConvert.SerializeObject(new
                    {
                        to    = tokenList,
                        title = notification.Title,
                        body  = notification.Description,
                        sound = "default"
                    }), ParameterType.RequestBody);
                    IRestResponse response = client.Execute(request);
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,LogoSrc,Name")] Drawer drawer)
        {
            if (ModelState.IsValid)
            {
                drawer.Id = Guid.NewGuid();
                _context.Add(drawer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            var allFiles = Directory.GetFiles($"{_env.WebRootPath}/Image/", "*.*", SearchOption.AllDirectories).ToList();

            for (int i = 0; i < allFiles.Count; i++)
            {
                allFiles[i] = allFiles[i].Replace(_env.WebRootPath, "");
            }
            ViewData["allFiles"] = allFiles;
            return(View(drawer));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("Id,CartoonId,ImageSrc")] CartoonImages cartoonImages)
        {
            if (ModelState.IsValid)
            {
                cartoonImages.Id = Guid.NewGuid();
                _context.Add(cartoonImages);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CartoonId"] = new SelectList(_context.Cartoon.OrderByDescending(x => x.Rank), "Id", "Id", cartoonImages.CartoonId);
            var allFiles = Directory.GetFiles($"{_env.WebRootPath}/Image/", "*.*", SearchOption.AllDirectories).ToList();

            for (int i = 0; i < allFiles.Count; i++)
            {
                allFiles[i] = allFiles[i].Replace(_env.WebRootPath, "");
            }
            ViewData["allFiles"] = allFiles;
            return(View(cartoonImages));
        }