コード例 #1
0
        public async Task <IActionResult> Index(string errorMessage = "", string successMessage = "")
        {
            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                ViewData["ErrorMessage"] = errorMessage;
            }
            if (!string.IsNullOrWhiteSpace(successMessage))
            {
                ViewData["SuccessMessage"] = successMessage;
            }

            LocationsResponse _LocationsResponse = new LocationsResponse();
            StocksResponse    _UnassignedStocks  = new StocksResponse();

            Guid _UserID = GetLoggedUserID();

            if (_UserID != Guid.Empty)
            {
                _LocationsResponse = await __LocationManager.GetByUserAsync(new GetLocationsByUserRequest { UID = _UserID });

                _UnassignedStocks = await __StockManager.GetByUserAsync(new GetStocksByUserRequest { UserUID = _UserID });
            }

            IndexViewModel _ViewModel = new IndexViewModel
            {
                Kitchens         = _LocationsResponse?.Locations?.ToViewModel().ToList() ?? Enumerable.Empty <NsModelsLocation.LocationViewModel>().ToList(),
                UnassignedStocks = _UnassignedStocks?.Stocks?.ToViewModel().ToList() ?? Enumerable.Empty <StockViewModel>().ToList()
            };

            return(View(_ViewModel));
        }
コード例 #2
0
        public bool Login(LoginDetails loginDetails)
        {
            _loginDetails = loginDetails;

            try
            {
                var client = getClient();

                Locations request = new Locations();
                request.q = "me";

                LocationsResponse response = client.Get <LocationsResponse>(request);



                if (response.Results != null && response.Results.Count > 0)
                {
                    return(true);
                }
                else
                {
                    _loginDetails = null;
                    return(false);
                }
            }
            catch
            {
                _loginDetails = null;
                throw;
            }
        }
コード例 #3
0
        public async Task <IActionResult> GetLocations()
        {
            var locations = await _locationService.GetAllLocations();

            var response = new LocationsResponse()
            {
                Locations = locations.Adapt <List <LocationDto> >()
            };

            return(Ok(response));
        }
コード例 #4
0
ファイル: DB.cs プロジェクト: SchmitzOri/SongDB
        internal static LocationsResponse Locations(Guid?songId)
        {
            using (SqlConnection conn = GetConnection())
            {
                LocationsResponse ret = new LocationsResponse()
                {
                    Locations = new List <LocationDTO>()
                };

                string command = "SELECT location_id, s.song_name, w.word, word_number_in_file, " +
                                 "verse_number, row_in_verse " +
                                 "FROM location l " +
                                 "JOIN song s ON s.song_id = l.song_id " +
                                 "JOIN word w ON w.word_id = l.word_id";

                if (songId.HasValue)
                {
                    command += " WHERE l.song_id = @song_id";
                }

                using (SqlCommand comm = new SqlCommand(command, conn))
                {
                    if (songId.HasValue)
                    {
                        comm.Parameters.AddWithValue("@song_id", songId);
                    }

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            ret.Locations.Add(new LocationDTO()
                            {
                                Id           = Guid.Parse(dr["location_id"].ToString()),
                                Word         = dr["word"].ToString(),
                                Song         = dr["song_name"].ToString(),
                                NumberInSong = int.Parse(dr["word_number_in_file"].ToString()),
                                VerseNumber  = int.Parse(dr["verse_number"].ToString()),
                                LineInVerse  = int.Parse(dr["row_in_verse"].ToString())
                            });
                        }

                        return(ret);
                    }
                }
            }
        }
コード例 #5
0
ファイル: DB.cs プロジェクト: SchmitzOri/SongDB
        internal static LocationsResponse WordByLocation(Guid songId, int numInSong,
                                                         int verseNum, int lineInVerse)
        {
            using (SqlConnection conn = GetConnection())
            {
                LocationsResponse ret = new LocationsResponse()
                {
                    Locations = new List <LocationDTO>()
                };

                string command = "SELECT location_id, s.song_name, w.word, word_number_in_file, " +
                                 "verse_number, row_in_verse " +
                                 "FROM location l " +
                                 "JOIN song s ON s.song_id = l.song_id " +
                                 "JOIN word w ON w.word_id = l.word_id " +
                                 "WHERE l.song_id = @song_id AND " +
                                 "(word_number_in_file = @num_in_file OR " +
                                 "verse_number = @verse_num AND row_in_verse = @verse_line)";

                using (SqlCommand comm = new SqlCommand(command, conn))
                {
                    comm.Parameters.AddWithValue("@song_id", songId);
                    comm.Parameters.AddWithValue("@num_in_file", numInSong);
                    comm.Parameters.AddWithValue("@verse_num", verseNum);
                    comm.Parameters.AddWithValue("@verse_line", lineInVerse);

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            ret.Locations.Add(new LocationDTO()
                            {
                                Id           = Guid.Parse(dr["location_id"].ToString()),
                                Word         = dr["word"].ToString(),
                                Song         = dr["song_name"].ToString(),
                                NumberInSong = int.Parse(dr["word_number_in_file"].ToString()),
                                VerseNumber  = int.Parse(dr["verse_number"].ToString()),
                                LineInVerse  = int.Parse(dr["row_in_verse"].ToString())
                            });
                        }

                        return(ret);
                    }
                }
            }
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                TrimClient trimClient = new TrimClient("http://[IPaddress]/HPECMServiceAPI");  // Change [IPaddress] to match your ServiceAPI machine
                trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

                long     PersonUri = 0;
                long     GroupUri  = 0;
                Location myloc     = new Location()
                {
                    Uri = PersonUri
                };                                                    // Change [PersonUri] to the person location you want to the member of a group location
                myloc.AddAction(
                    new AddRelationship()
                {
                    RelatedLocation = new LocationRef()
                    {
                        Uri = GroupUri
                    },                                                           // Change [GroupUri] to the group location you want to add the membership to
                    RelationshipType = LocRelationshipType.MemberOf,
                    MakeThisTheDefaultRelationship = false
                }
                    );
                LocationsResponse locresp1 = trimClient.Post <LocationsResponse>(myloc);

                if (locresp1.ResponseStatus.Message != null)
                {
                    MessageBox.Show(locresp1.ResponseStatus.Message);
                }
                else
                {
                    MessageBox.Show("Association Updated");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }