public async Task <ActionResult <UpdatesModel> > PostUpdatesModel(UpdatesModel updatesModel)
        {
            _context.UpdatesModels.Add(updatesModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUpdatesModel", new { id = updatesModel.UpdatesModelId }, updatesModel));
        }
Пример #2
0
        public static List <UpdatesModel> GetListOfUpdates(string username)
        {
            int id = 0;

            //fetch the userid. Handle the exception when the username is empty
            try
            {
                id = FetchUserId(username);
            }
            catch
            {
            }
            List <UpdatesModel> lstupdates = new List <UpdatesModel>();

            using (var db = new UsersContext())
            {
                var updates = db.Updates.OrderByDescending(f => f.datecreated).ToList();
                if (String.IsNullOrEmpty(username))
                {
                    db.Updates.OrderByDescending(f => f.datecreated).ToList();
                }
                db.Updates.OrderByDescending(f => f.datecreated).ToList();
                foreach (Updates up in updates)
                {
                    var upmodel = new UpdatesModel();
                    upmodel.data         = up.data;
                    upmodel.datecreated  = up.datecreated;
                    upmodel.datemodified = up.datemodified;
                    upmodel.status       = up.status;
                    upmodel.updateid     = up.updateid;
                    upmodel.userid       = up.userid;
                    var updateuser = GetUserDetailsId(up.userid);
                    upmodel.updatename = updateuser.firstname + " " + updateuser.lastname;
                    upmodel.comments   = new List <CommentsModel>();
                    var comments = db.Comments.Where(f => up.updateid == f.updateid).OrderByDescending(f => f.datecreated).ToList();
                    foreach (Comments cm in comments)
                    {
                        var cmmodel = new CommentsModel();
                        cmmodel.data      = cm.data;
                        cmmodel.commentid = cm.commentid;
                        var commentuser = GetUserDetailsId(cm.userid);
                        cmmodel.commentsname = commentuser.firstname + " " + commentuser.lastname;
                        cmmodel.datecreated  = cm.datecreated;
                        cmmodel.datemodified = cm.datemodified;
                        cmmodel.status       = cm.status;
                        cmmodel.updateid     = cm.updateid;
                        cmmodel.userid       = cm.userid;
                        upmodel.comments.Add(cmmodel);
                    }
                    lstupdates.Add(upmodel);
                }
                return(lstupdates);
            }
        }
Пример #3
0
        public ActionResult UpdateModule()
        {
            try {
                WebProjectManager[] projectManagers = GetProjectManagers();
                var installed = new List <InstallationState>();
                foreach (var projectManager in projectManagers)
                {
                    var installedPackages     = this.GetInstalledPackages(projectManager);
                    var packagesList          = installedPackages.GroupBy(x => x.Id);
                    var installedPackagesList = packagesList.Select(pack => pack.Single(y => y.Version == pack.Max(x => x.Version))).ToList();

                    foreach (var installedPackage in installedPackagesList)
                    {
                        IPackage update  = projectManager.GetUpdatedPackage(installedPackage);
                        var      package = new InstallationState();
                        package.Installed = installedPackage;
                        package.Update    = update;
                        package.Source    = projectManager.SourceRepository.Source;

                        if (installed.Any(d => d.Installed.Id == package.Installed.Id))
                        {
                            var addedPackage = installed.Where(d => d.Installed.Id == package.Installed.Id).First();
                            if (package.Update != null)
                            {
                                if (addedPackage.Update == null || addedPackage.Update.Version < package.Update.Version)
                                {
                                    installed.Remove(addedPackage);
                                    installed.Add(package);
                                }
                            }
                        }
                        else
                        {
                            installed.Add(package);
                        }
                    }
                }

                var model = new UpdatesModel();
                model.Updates = installed;


                return(View(model));
            }
            catch (Exception e) {
                ErrorHandler.Publish(LogLevel.Error, "Nuget Get packages from feed", e);
                return(View("ExceptionError"));
            }
        }
        public async Task <IActionResult> PutUpdatesModel(int id, UpdatesModel updatesModel)
        {
            var aux = DateTime.Now;

            _context.Entry(updatesModel).State = EntityState.Modified;
            Console.WriteLine(updatesModel);
            if (id == 0)
            {
                updatesModel.LegalDaysUpdateTime = aux;
            }
            if (id == 1)
            {
                updatesModel.FormulaUpdateTime = aux;
            }
            if (id == 2)
            {
                updatesModel.SRUpdateTime = aux;
            }
            if (id == 3)
            {
                updatesModel.SubDomainsUpdateTime = aux;
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UpdatesModelExists(1))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #5
0
        // This method is used for general queries
        public static object sendQuery(string address, string pw)
        {
            Tuple <string, UInt16> addr = splitAddr(address);
            string addrIP = addr.Item1;
            string score;
            UInt16 port = addr.Item2;

            using (var server = ServerQuery.GetServerInstance(
                       (Game)appId,
                       addrIP,
                       port,
                       throwExceptions: false,
                       retries: retries)) {
                var serverInfo = server.GetInfo();

                score = !String.IsNullOrEmpty(pw) ? getPugScore(server, pw) : "Bad RCON PW";

                UpdatesModel su = new UpdatesModel(serverInfo, score);
                return(su);
                // return serverInfo;
            }
        }
Пример #6
0
        public SampleMainVM()
        {
            Updates   = new UpdatesModel();
            MatchList = new ObservableCollection <MatchModel>();

            FilterVM.ShowMoreFiltering = true;

            MatchModel Dolores = new MatchModel()
            {
                Id     = "123",
                Person = new PersonModel()
                {
                    Id        = "123",
                    Name      = "Dolores",
                    Bio       = "Hi, I'm Dolores :p",
                    Gender    = 1,
                    BirthDate = new DateTime(1987, 9, 7),
                    Photos    = new ObservableCollection <PhotoModel>()
                    {
                        new PhotoModel()
                        {
                            Url = @"D:\Documents\Visual Studio 2015\Projects\twinder\SampleData\DoloresPics\dolores1.jpg",

                            ProcessedFiles = new ObservableCollection <ProcessedFileModel>()
                            {
                                new ProcessedFileModel()
                                {
                                    Url = @"D:\Documents\Visual Studio 2015\Projects\twinder\SampleData\DoloresPics\dolores1.jpg"
                                },
                                new ProcessedFileModel()
                                {
                                    Url = @"D:\Documents\Visual Studio 2015\Projects\twinder\SampleData\DoloresPics\dolores1.jpg"
                                },
                                new ProcessedFileModel()
                                {
                                    Url = @"D:\Documents\Visual Studio 2015\Projects\twinder\SampleData\DoloresPics\dolores1.jpg"
                                }
                            }
                        }
                    }
                },
                Messages = new ObservableCollection <MessageModel>()
                {
                    new MessageModel()
                    {
                        From     = "123",
                        SentDate = new DateTime(2016, 11, 10, 17, 5, 6),
                        Message  = "You're the best Dainius"
                    }
                },
                MessageCount     = 1,
                CreatedDate      = new DateTime(2016, 11, 9, 0, 1, 2),
                LastActivityDate = new DateTime(2016, 11, 11, 2, 3, 4),
                IsSuperLike      = true
            };

            RecList = new ObservableCollection <RecModel>();
            RecList.Add(new RecModel());

            MatchList.Add(Dolores);
        }